appium / appium

Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
http://appium.io/
Apache License 2.0
18.82k stars 6.07k forks source link

bug: WDA getStatus keeps waiting when giving wdaLocalPort #19926

Closed saikrishna321 closed 6 months ago

saikrishna321 commented 6 months ago

Do I have the most recent component updates?

Is the component officially supported by the Appium team?

Is there an existing issue for this?

Current Behavior

When creating a session with preinstalledWda and setting wdaLocalPort to random port is failing to getStatus.

When wdaLocalPort capability points to default port 8100 everything works fine.

Expected Behavior

Session creation should be successful.

Minimal Reproducible Example

import { remote } from 'webdriverio';
const APPIUM_HOST = 'localhost';
const APPIUM_PORT = 4723;
const WDIO_PARAMS = {
  hostname: APPIUM_HOST,
  port: APPIUM_PORT,
  path: '/wd/hub/',
  logLevel: 'info',
};
const capabilities = {
  platformName: 'ios',
  'appium:automationName': 'XCUITest',
  'appium:udid': '',
  'appium:usePreinstalledWDA': true,
  'appium:updatedWDABundleIdSuffix': '',
  'appium:updatedWDABundleId': 'atd.pro',
  'appium:showXcodeLog': true,
  'appium:mjpegServerPort': 9100,
  'appium:wdaLocalPort': 9900,
};
describe('Plugin1 Test', () => {
  let driver;
  beforeEach(async () => {
    driver = await remote({ ...WDIO_PARAMS, capabilities });
  });

  it('iOS veritical swipe', async () => {

  });

  afterEach(async () => await driver.deleteSession());
});

Environment

Link to Appium Logs

No response

Further Information

Success logs - https://gist.github.com/saikrishna321/0ee273dbdcb9b65dc0868c1ad4f7a1d3 UnSuccess logs - https://gist.github.com/saikrishna321/f2132d2945bcb26b3c92e64960ad86f6

saikrishna321 commented 6 months ago

can confirm WDA is launched in the device successfully.

[XCUITestDriver@9ab2 (aaccdfbf)] WDA is not listening at 'http://127.0.0.1:9900/'
[XCUITestDriver@9ab2 (aaccdfbf)] Event 'wdaStartFailed' logged at 1711510404398 (11:33:24 GMT+0800 (Singapore Standard Time))
[XCUITestDriver@9ab2 (aaccdfbf)] Error: Failed to start the preinstalled WebDriverAgent in 60000 ms. The WebDriverAgent might not be properly built or the device might be locked. The 'appium:wdaLaunchTimeout' capability modifies the timeout.
[XCUITestDriver@9ab2 (aaccdfbf)]     at WebDriverAgent._launchViaDevicectl (/Users/saikrishna/Downloads/git/appium-device-farm/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent/lib/webdriveragent.js:330:13)
[XCUITestDriver@9ab2 (aaccdfbf)]     at runMicrotasks (<anonymous>)
[XCUITestDriver@9ab2 (aaccdfbf)]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[XCUITestDriver@9ab2 (aaccdfbf)]     at WebDriverAgent.launchWithPreinstalledWDA (/Users/saikrishna/Downloads/git/appium-device-farm/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent/lib/webdriveragent.js:357:9)
[XCUITestDriver@9ab2 (aaccdfbf)]     at WebDriverAgent.launch (/Users/saikrishna/Downloads/git/appium-device-farm/node_modules/appium-xcuitest-driver/node_modules/appium-webdriveragent/lib/webdriveragent.js:411:14)
[XCUITestDriver@9ab2 (aaccdfbf)]     at /Users/saikrishna/Downloads/git/appium-device-farm/node_modules/appium-xcuitest-driver/lib/driver.js:822:34
[XCUITestDriver@9ab2 (aaccdfbf)]     at wrapped (/Users/saikrishna/Downloads/git/appium-device-farm/node_modules/appium-xcuitest-driver/node_modules/asyncbox/lib/asyncbox.js:93:13)
[XCUITestDriver@9ab2 (aaccdfbf)]     at retry (/Users/saikrishna/Downloads/git/appium-device-farm/node_modules/appium-xcuitest-driver/node_modules/asyncbox/lib/asyncbox.js:66:13)
[XCUITestDriver@9ab2 (aaccdfbf)]     at retryInterval (/Users/saikrishna/Downloads/git/appium-device-farm/node_modules/appium-xcuitest-driver/node_modules/asyncbox/lib/asyncbox.js:103:10)
[XCUITestDriver@9ab2 (aaccdfbf)]     at /Users/saikrishna/Downloads/git/appium-device-farm/node_modules/appium-xcuitest-driver/lib/driver.js:812:7
[XCUITest] The executable name for the bundle id 'atd.pro' was 'WebDriverAgentRunner-Runner'
KazuCocoa commented 6 months ago

It looks like the launching argument order should be:

% xcrun devicectl device process launch --device 00008020-000E5CDA0A23002E --terminate-existing --environment-variables '{"USE_PORT":"9900","WDA_PRODUCT_BUNDLE_IDENTIFIER":"com.trident.WebDriverAgentRunner.xctrunner"}' com.trident.WebDriverAgentRunner.xctrunner

I tested with the caps, but modified the order as part of pr. No error occurred in the modification so i thought it worked but the command was order sensitive...

saikrishna321 commented 6 months ago

@KazuCocoa You mean launch WDA n then we port forward?

KazuCocoa commented 6 months ago

No, https://github.com/appium/appium-xcuitest-driver/pull/2366 fixes it. The devicectl command silently ignore arguments in some wrong order case. The fix modify the order to make it work properly

KazuCocoa commented 6 months ago

7.6.1 should be ok

saikrishna321 commented 6 months ago

@KazuCocoa I have "appium:mjpegServerPort": 8900 https://gist.github.com/saikrishna321/d2b4f34ec6e3840ae00e1cea7b5011c6 and I don't see a portforward happening for this.

KazuCocoa commented 6 months ago

I think Appium takes care the portforward for video stream only during recording. https://github.com/appium/appium-xcuitest-driver/blob/be49758ecf1e7def8b148c4f2ead7975c83e03f5/lib/commands/recordscreen.js#L58-L61