AppiumTestDistribution / appium-device-farm

This is an Appium 2.0 plugin designed to manage and create driver sessions on available devices.
https://devicefarm.org
Other
333 stars 103 forks source link

Appium server not getting started locally for IOS | xcodebuild exited with code '65' and signal 'null' | Browserstack handshake issue for iOS execution #742

Closed LavanyaJK closed 1 year ago

LavanyaJK commented 1 year ago

@anandbagmar @saikrishna321 I am facing issue while running IOS testcase on local, have installed appium, plugins and drivers locally in the AppiumTestDistribution directory using below commands,

npm install appium

npm install appium-uiautomator2-driver

npm install appium-device-farm

npm install go-ios

Android runs are working perfectly fine.

For IOS, the simulator(booted) is found, and able to get the device from device-farm, but appium server is not starting in the local, Used this command to run on iOS--> Platform='iOS' CONFIG_FILE='./configs/iOSConfig.properties' mvn clean -Dtest=Runner test -Dcheckstyle.skip

Please find the logs below,

[INFO] Running com.test.site.Runner SLF4J: No SLF4J providers were found. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details. INFO [main] (ConfigFileManager.java:35)- Using config file from [./configs/iOSConfig.properties] INFO [main] (AppiumServerManager.java:51)- com.appium.manager.AppiumServerManagerStarting Appium Server on Localhost 35m[Adirectoryppium], ls tat.java:101)- Picking UserSpecified Path for AppiumServiceBuilder at Object.lstatSync (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/graceful-fs/polyfills.js:318:34) [debug] [Appium] at statFunc (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/fs-extra/lib/util/stat.js:24:20) [debug] [Appium] at getStatsSync (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/fs-extra/lib/util/stat.js:25:19) [debug] [Appium] at Object.checkPathsSync (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/fs-extra/lib/util/stat.js:67:33) [debug] [Appium] at Object.copySync (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/fs-extra/lib/copy/copy-sync.js:27:38) [debug] [Appium] at derivedPathExtracted (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/device-managers/IOSDeviceManager.js:99:36) [debug] [Appium] at IOSDeviceManager.derivedDataPath (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/device-managers/IOSDeviceManager.js:117:17) [debug] [Appium] at IOSDeviceManager. (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/device-managers/IOSDeviceManager.js:225:307) [debug] [Appium] at Generator.next ()t' ] } [debug] [Appium] at fulfilled (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/device-managers/IOSDeviceManager.js:5:58) [debug] [Appium] at processTicksAndRejections (node:internal/process/task_queues:95:5)Distribution/node_modules/appium-xcuitest-driver [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 60.689 s <<< FAILURE! - in com.test.site.Runner [ERROR] testApp(com.test.site.Runner) Time elapsed: 60.403 s <<< FAILURE!etup/AppiumTestDistribution/node_modules/appium-uiautomator2-driver io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: device-farm [The local appium server has not been started, Reason: Timed out waiting for [http://127.0.0.1:3639/wd/hub/status] to be available after 60006 ms, Consider increasing the server startup timeout value (currently 60000ms), Node.js executable path: /opt/homebrew/bin/node, Arguments: [/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium/build/lib/main.js, --port, 3639, --address, 127.0.0.1, --log, /Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/target/appiumlogs/appium_logs.txt, --base-path, /wd/hub/, --relaxed-security, --config, /Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/target/server.json], Output: [Appium] Attempting to load plugin device-farm...NT: no such fie:fs:1593:3) [debug] [Appi5m[Apirectory,pium] m st aatlavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm t Object.lstatSync (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/graceful-fs/polyfills.js:318:34) [debug] [Appium] at statFunc (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/fs-extra/lib/util/stat.js:24:20) [debug] [Appium] at getStatsSync (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/fs-extra/lib/util/stat.js:25:19) [debug] [Appium] at Object.checkPathsSync (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/fs-extra/lib/util/stat.js:67:33) [debug] [Appium] at Object.copySync (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/fs-extra/lib/copy/copy-sync.js:27:38) [debug] [Appium] at derivedPathExtracted (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/device-managers/IOSDeviceManager.js:99:36) [debug] [Appium] at IOSDeviceManager.derivedDataPath (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/device-managers/IOSDeviceManager.js:117:17) [debug] [Appium] at IOSDeviceManager. (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/device-managers/IOSDeviceManager.js:225:307) [debug] [Appium] at Generator.next ()jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-xcuitest-driver [debug] [Appium] at fulfilled (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/device-managers/IOSDeviceManager.js:5:58) [debug] [Appium] at processTicksAndRejections (node:internal/process/task_queues:95:5)Distribution/node_modules/appium-uiautomator2-driver ]device-farm] ???????????? Device Farm Plugin will be served at ???? http://localhost:3639/device-farm [device-at com.test.site.Runner.testApp(Runner.java:27) Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://127.0.0.1:3639/wd/hub/status] to be available after 60006 ms [Appium]at com.test.site.Runner.testApp(Runner.java:27)p[35osm[Appium]ible tm Errhat a driver or plor: Eugin tNOENT: no such file or directory, lstat Caused by: java.util.concurrent.TimeoutException to update the server and failed. Original error:de ENOENT: no such fil:fs:1593:3) [dee orbat com.test.site.Runner.testApp(Runner.java:27)

Please provide the solution, and thank you in advance.

saikrishna321 commented 1 year ago

Can you post full server logs please

saikrishna321 commented 1 year ago

@LavanyaJK I'm unable to reproduce the issue

https://gist.github.com/saikrishna321/4563c0f70078a8c74f15200dd4883e61

Capabilities are as

{
  "iOS": {
    "platformName": "iOS",
    "app": "./apps/VodQAReactNative.zip",
    "deviceName": "iPhone",
    "preventWDAAttachments": true,
    "clearSystemFiles": true,
    "shouldUseSingletonTestManager": false,
    "simpleIsVisibleCheck": true,
    "maxTypingFrequency": 10,
    "automationName": "XCUITest",
    "usePrebuiltWDA": true,
    "appium:iPhoneOnly": true
  },
  "serverConfig" : {
    "server": {
      "use-plugins": ["device-farm", "element-wait"],
      "plugin": {
        "device-farm": {
          "platform": "iOS",
          "skipChromeDownload": true
        }
      }
    }
  },
  "appiumServerPath": "./node_modules/appium/build/lib/main.js"
}

server.json

{
  "server": {
    "plugin": {
      "device-farm": {
        "skipChromeDownload": true,
        "platform": "both"
      }
    },
    "port": 31337,
    "use-plugins": ["device-farm"]
  }
}
LavanyaJK commented 1 year ago

Hi @saikrishna321,

Once we removed the "derivedDataPath" from caps, the test case executed successfully on local. "derivedDataPath": { "simulator": "" }

After these changes, WebDriverAgentRunner-Runner.app was not able to launch, and below error was showing up, [Xcode] xcodebuild exited with code '65' and signal 'null' [debug] [XCUITestDriver@7898 (cd13f036)] Event 'wdaStartFailed' logged at 1689162671877 (17:21:11 GMT+0530 (India Standard Time)) [debug] [XCUITestDriver@7898 (cd13f036)] Unable to launch WebDriverAgent because of xcodebuild failure: xcodebuild failed with code 65 [debug] [XCUITestDriver@7898 (cd13f036)] xcodebuild error message: [debug] [XCUITestDriver@7898 (cd13f036)] [XCUITestDriver@7898 (cd13f036)] Quitting and uninstalling WebDriverAgent [XCUITestDriver@7898 (cd13f036)] Shutting down sub-processes [debug] [XCUITestDriver@7898 (cd13f036)] No WDAs on the device.

so we made a change by setting usePrebuiltWDA to false in iOScapabilities file, which resolved this issue, and IOS ran successfully in local.

But now I tried running a testcase on BrowserStack, it is getting failed due to handshake issue.

Command used to run the test case -> Platform='android' CLOUD_KEY={user_key} CLOUD_USERNAME={user_name} CONFIG_FILE='./configs/bs_config.properties' mvn clean -Dtest=Runner test -Dcheckstyle.skip

And the capabilities I used is - { "iOS": { "platformName": "iOS", "app": { "simulator": "https://github.com/saikrishna321/AppiumTestDistribution/blob/master/apps/VodQAReactNative.zip?raw=true" }, "deviceName": "iPhone", "wdaLaunchTimeout": 80000, "wdaConnectionTimeout": 80000, "preventWDAAttachments": true, "clearSystemFiles": true, "shouldUseSingletonTestManager": false, "simpleIsVisibleCheck": true, "maxTypingFrequency": 10 }, "serverConfig" : { "server": { "use-plugins": ["device-farm"], "plugin": { "device-farm": { "platform": "iOS", "skipChromeDownload": true, "cloud": { "cloudName": "browserstack", "url": "http://hub-cloud.browserstack.com", "devices": [ { "deviceName": "iPhone 11 Pro", "os_version": "15", "platform": "ios" } ] } } } } }, "appiumServerPath": "./node_modules/appium/build/lib/main.js" }

Please find the complete logs below-

INFO [main] (ATDRunner.java:81)- com.appium.manager.ATDRunnerTotal Number of devices detected::1

... ... TestNG 7.5 by C?dric Beust (cedric@beust.com) ...

[HTTP] --> GET /device-farm/api/cliArgs [HTTP] {} [HTTP] <-- GET /device-farm/api/cliArgs 200 1 ms - 1123 [HTTP] INFO [TestNG-test=ATDTest-1] (DesiredCapabilityBuilder.java:27)- Capabilities file is not specified. Using default capabilities file INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:94)- startAppiumDriverInstance for dragNDrop using capability file: ./caps/browserstack.json INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:96)- startAppiumDriverInstance INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:41)- Initialise Driver with Capabilities: INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:42)- app:: {"simulator":"https://github.com/saikrishna321/AppiumTestDistribution/blob/master/apps/VodQAReactNative.zip?raw=true"} INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:42)- clearSystemFiles:: true INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:42)- deviceName:: iPhone INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:42)- maxTypingFrequency:: 10 INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:42)- platformName:: IOS INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:42)- preventWDAAttachments:: true INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:42)- shouldUseSingletonTestManager:: false INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:42)- simpleIsVisibleCheck:: true INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:42)- wdaConnectionTimeout:: 80000 INFO [TestNG-test=ATDTest-1] (AppiumDriverManager.java:42)- wdaLaunchTimeout:: 80000 [debug] [HTTP] Request idempotency key: ddc67e79-af6a-4747-8cfd-1c9dc4582853 [HTTP] --> POST /wd/hub/session [HTTP] {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"appium:app":"{\"simulator\":\"https://github.com/saikrishna321/AppiumTestDistribution/blob/master/apps/VodQAReactNative.zip?raw=true\"}","appium:clearSystemFiles":true,"appium:deviceName":"iPhone","appium:maxTypingFrequency":10,"appium:preventWDAAttachments":true,"appium:shouldUseSingletonTestManager":false,"appium:simpleIsVisibleCheck":true,"appium:wdaConnectionTimeout":80000,"appium:wdaLaunchTimeout":80000,"platformName":"IOS"}}} [debug] [AppiumDriver@2849] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{}],"alwaysMatch":{"appium:app":"{\"simulator\":\"https://github.com/saikrishna321/AppiumTestDistribution/blob/master/apps/VodQAReactNative.zip?raw=true\"}","appium:clearSystemFiles":true,"appium:deviceName":"iPhone","appium:maxTypingFrequency":10,"appium:preventWDAAttachments":true,"appium:shouldUseSingletonTestManager":false,"appium:simpleIsVisibleCheck":true,"appium:wdaConnectionTimeout":80000,"appium:wdaLaunchTimeout":80000,"platformName":"IOS"}}] [AppiumDriver@2849] Plugins which can handle cmd 'createSession': device-farm [AppiumDriver@2849] Plugin device-farm is now handling cmd 'createSession' { 'appium:app': '{"simulator":"https://github.com/saikrishna321/AppiumTestDistribution/blob/master/apps/VodQAReactNative.zip?raw=true"}', 'appium:clearSystemFiles': true, 'appium:deviceName': 'iPhone', 'appium:maxTypingFrequency': 10, 'appium:preventWDAAttachments': true, 'appium:shouldUseSingletonTestManager': false, 'appium:simpleIsVisibleCheck': true, 'appium:wdaConnectionTimeout': 80000, 'appium:wdaLaunchTimeout': 80000, platformName: 'IOS' } [device-farm] {"platform":"ios","name":"","deviceType":"real","busy":false,"userBlocked":false} [device-farm] Waiting for free device [device-farm] 📱 Device found: {"os_version":"15","deviceName":"iPhone 11 Pro","platform":"ios","host":"http://hub-cloud.browserstack.com","busy":false,"userBlocked":false,"deviceType":"real","capability":{"os_version":"15","deviceName":"iPhone 11 Pro","platform":"ios"},"cloud":"browserstack","name":"iPhone 11 Pro","sdk":"15","udid":"iPhone 11 Pro","offline":false,"meta":{"revision":0,"created":1689173004809,"version":0},"$loki":1} [device-farm] 📱 Blocking device iPhone 11 Pro for new session [device-farm] Updating cloud Capability for Device [device-farm] Remote Host URL - https://lavanyajk_eLORhQ:ZUQCK3vxTNcbN7eNPzqm@hub-cloud.browserstack.com/wd/hub/session [device-farm] Creating cloud session [HPM] Proxy created: / -> http://hub-cloud.browserstack.com [HPM] Subscribed to http-proxy events: [ 'proxyReq', 'error', 'close' ] [device-farm] 📱 Updating Device iPhone 11 Pro with session ID undefined [AppiumDriver@2849] Command 'createSession' was not handled by the following behaviours or plugins, even though they were registered to handle it: ["default"]. The command was handled by these: ["device-farm"]. [AppiumDriver@2849] Promoting 1 sessionless plugins to be attached to session ID undefined [debug] [AppiumDriver@2849] Cached the protocol value 'W3C' for the new session undefined [debug] [AppiumDriver@2849] Responding to client with driver.createSession() result: {} [HTTP] <-- POST /wd/hub/session 200 1493 ms - 12 [HTTP] org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Handshake response does not match any supported protocol. Response payload: {"value":{}} Host info: host: 'LM0003404', ip: '2409:408c:8d85:62c:d81e:c00e:d884:2223%en0' Build info: version: '4.10.0', revision: 'c14d967899' System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '12.6.3', java.version: '11.0.19' Driver info: io.appium.java_client.ios.IOSDriver Command: [null, newSession {capabilities=[{appium:app={"simulator":"https://github.com/saikrishna321/AppiumTestDistribution/blob/master/apps/VodQAReactNative.zip?raw=true"}, appium:clearSystemFiles=true, appium:deviceName=iPhone, appium:maxTypingFrequency=10, platformName=IOS, appium:preventWDAAttachments=true, appium:shouldUseSingletonTestManager=false, appium:simpleIsVisibleCheck=true, appium:wdaConnectionTimeout=80000, appium:wdaLaunchTimeout=80000}], desiredCapabilities=Capabilities {app: {"simulator":"https://githu..., clearSystemFiles: true, deviceName: iPhone, maxTypingFrequency: 10, platformName: IOS, preventWDAAttachments: true, shouldUseSingletonTestManager: false, simpleIsVisibleCheck: true, wdaConnectionTimeout: 80000, wdaLaunchTimeout: 80000}}] Capabilities {app: {"simulator":"https://githu..., clearSystemFiles: true, deviceName: iPhone, maxTypingFrequency: 10, platformName: IOS, preventWDAAttachments: true, shouldUseSingletonTestManager: false, simpleIsVisibleCheck: true, wdaConnectionTimeout: 80000, wdaLaunchTimeout: 80000} at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$2(ProtocolHandshake.java:154) at java.base/java.util.Optional.orElseGet(Optional.java:369) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:150) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:133) at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:102) at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:182) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:250) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:531) at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:274) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:154) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:89) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:101) at io.appium.java_client.ios.IOSDriver.(IOSDriver.java:104) at com.appium.manager.AppiumDriverManager.createAppiumDriver(AppiumDriverManager.java:56) at com.appium.manager.AppiumDriverManager.initialiseDriver(AppiumDriverManager.java:46) at com.appium.manager.AppiumDriverManager.startAppiumDriverInstance(AppiumDriverManager.java:98) at com.appium.manager.AppiumDriverManager.startAppiumDriverInstance(AppiumDriverManager.java:83) at com.appium.manager.AppiumParallelMethodTestListener.allocateDeviceAndStartDriver(AppiumParallelMethodTestListener.java:101) at com.appium.manager.AppiumParallelMethodTestListener.beforeInvocation(AppiumParallelMethodTestListener.java:74) at org.testng.internal.invokers.InvokedMethodListenerInvoker.invokeListener(InvokedMethodListenerInvoker.java:55) at org.testng.internal.invokers.BaseInvoker.runInvokedMethodListeners(BaseInvoker.java:67) at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:641) at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:220) at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50) at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:945) at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:193) at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) INFO [TestNG-test=ATDTest-1] (AppiumParallelMethodTestListener.java:122)- Driver Session exisstsfalsenull INFO [TestNG-test=ATDTest-1] (SessionContext.java:25)- SessionContext default constructor INFO [TestNG-test=ATDTest-1] (SessionContext.java:51)- Using reportportal.properties file from src/test/resources/reportportal.properties INFO [TestNG-test=ATDTest-1] (SessionContext.java:57)- Loaded reportportal.properties file - /Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/src/test/resources/reportportal.properties INFO [TestNG-test=ATDTest-1] (SessionContext.java:29)- Initialized SessionContext INFO [TestNG-test=ATDTest-1] (SessionContext.java:42)- Removing context for thread - 27 com.appium.executor.CustomeListener.afterInvocation() was invoked FAILED: dragNDrop java.lang.IllegalArgumentException: Input must be set at org.openqa.selenium.internal.Require.nonNull(Require.java:60) at org.openqa.selenium.support.ui.FluentWait.(FluentWait.java:94) at org.openqa.selenium.support.ui.WebDriverWait.(WebDriverWait.java:74) at org.openqa.selenium.support.ui.WebDriverWait.(WebDriverWait.java:43) at com.test.site.UserBaseTest.waitForElement(UserBaseTest.java:26) at com.test.site.UserBaseTest.login(UserBaseTest.java:22) at com.test.site.SliderTest.dragNDrop(SliderTest.java:12) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:135) at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:673) at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:220) at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50) at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:945) at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:193) at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)

Please provide your inputs on this.

cc: @anandbagmar

saikrishna321 commented 1 year ago

@LavanyaJK Does your test work on Browserstack outside ATD?

ATD has browserstack test and it passes - https://app.circleci.com/pipelines/github/AppiumTestDistribution/AppiumTestDistribution/192/workflows/6b1f505a-756e-437f-8fea-265e4c6548de/jobs/601

I noticed that you are sending the app as GitHub url, I think with Browserstack you need to upload the app and give something like bs://someidgeneeatedbybs

I don't know if browserstack allows download of app from remote url.

LavanyaJK commented 1 year ago

Hi @saikrishna321,

Yes, I have executed testcases on BrowserStack outside ATD, but only worked on Android, not on IOS,

I just checked android case on browserstack, it executed successfully,

image

But for iOS, below error message appears,

[debug] [AppiumDriver@0346] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{}],"alwaysMatch":{"appium:app":"bs://4e4e5743713d29a3599946e9949979cf9e20375f","appium:automationName":"XCUITest","appium:browserstack.appium_version":"2.0.0","appium:browserstack.debug":true,"appium:clearSystemFiles":true,"appium:deviceName":"iPhone","appium:maxTypingFrequency":10,"appium:preventWDAAttachments":true,"appium:shouldUseSingletonTestManager":false,"appium:simpleIsVisibleCheck":true,"appium:wdaConnectionTimeout":80000,"appium:wdaLaunchTimeout":80000,"platformName":"IOS"}}] [AppiumDriver@0346] Plugins which can handle cmd 'createSession': device-farm [AppiumDriver@0346] Plugin device-farm is now handling cmd 'createSession' { 'appium:app': 'bs://4e4e5743713d29a3599946e9949979cf9e20375f', 'appium:automationName': 'XCUITest', 'appium:browserstack.appium_version': '2.0.0', 'appium:browserstack.debug': true, 'appium:clearSystemFiles': true, 'appium:deviceName': 'iPhone', 'appium:maxTypingFrequency': 10, 'appium:preventWDAAttachments': true, 'appium:shouldUseSingletonTestManager': false, 'appium:simpleIsVisibleCheck': true, 'appium:wdaConnectionTimeout': 80000, 'appium:wdaLaunchTimeout': 80000, platformName: 'IOS' } [device-farm] {"platform":"ios","name":"","deviceType":"real","busy":false,"userBlocked":false} [device-farm] Waiting for free device [device-farm] 📱 Device found: {"os_version":"15","deviceName":"iPhone 11 Pro","platform":"ios","host":"http://hub-cloud.browserstack.com","busy":false,"userBlocked":false,"deviceType":"real","capability":{"os_version":"15","deviceName":"iPhone 11 Pro","platform":"ios"},"cloud":"browserstack","name":"iPhone 11 Pro","sdk":"15","udid":"iPhone 11 Pro","offline":false,"meta":{"revision":0,"created":1689183697258,"version":0},"$loki":1} [device-farm] 📱 Blocking device iPhone 11 Pro for new session [device-farm] Updating cloud Capability for Device [device-farm] Remote Host URL - https://lavanyajk_eLORhQ:ZUQCK3vxTNcbN7eNPzqm@hub-cloud.browserstack.com/wd/hub/session [device-farm] Creating cloud session No tvOS simulators found! uncaughtException: Cannot destructure property 'state' of 'allDevices.find(...)' as it is undefined. TypeError: Cannot destructure property 'state' of 'allDevices.find(...)' as it is undefined. at /Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/data-service/device-service.js:45:21 at Array.forEach () at setSimulatorState (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/data-service/device-service.js:42:13) at /Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/device-utils.js:276:58 at Generator.next () at fulfilled (/Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/node_modules/appium-device-farm/lib/device-utils.js:5:58) at processTicksAndRejections (node:internal/process/task_queues:95:5) org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. Host info: host: 'LM0003404', ip: '2409:408c:8d85:62c:d81e:c00e:d884:2223%en0' at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:549) at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:274) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:154) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:89) at io.appium.java_client.AppiumDriver.(AppiumDriver.java:101) at io.appium.java_client.ios.IOSDriver.(IOSDriver.java:104) at com.appium.manager.AppiumDriverManager.createAppiumDriver(AppiumDriverManager.java:56) at com.appium.manager.AppiumDriverManager.initialiseDriver(AppiumDriverManager.java:46) at com.appium.manager.AppiumDriverManager.startAppiumDriverInstance(AppiumDriverManager.java:98) at com.appium.manager.AppiumDriverManager.startAppiumDriverInstance(AppiumDriverManager.java:83) at com.appium.manager.AppiumParallelMethodTestListener.allocateDeviceAndStartDriver(AppiumParallelMethodTestListener.java:101) at com.appium.manager.AppiumParallelMethodTestListener.beforeInvocation(AppiumParallelMethodTestListener.java:74) at org.testng.internal.invokers.InvokedMethodListenerInvoker.invokeListener(InvokedMethodListenerInvoker.java:55) at org.testng.internal.invokers.BaseInvoker.runInvokedMethodListeners(BaseInvoker.java:67) at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:641) at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:220) at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50) at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:945) at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:193) at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException Build info: version: '4.10.0', revision: 'c14d967899' System info: os.name: 'Mac OS X', os.arch: 'aarch64', os.version: '12.6.3', java.version: '11.0.19' Driver info: driver.version: IOSDriver at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:137) at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:102) at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:182) at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:250) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:531) ... 23 more Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at io.appium.java_client.remote.AppiumProtocolHandshake.createSession(AppiumProtocolHandshake.java:133) ... 27 more Caused by: java.io.UncheckedIOException: org.asynchttpclient.exception.RemotelyClosedException: Remotely closed at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:73) at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) at io.appium.java_client.remote.AppiumCommandExecutor.lambda$null$0(AppiumCommandExecutor.java:187) at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:55) at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:48) at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) at io.appium.java_client.remote.AppiumCommandExecutor.lambda$null$0(AppiumCommandExecutor.java:187) at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:55) at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:97) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:115) ... 32 more Caused by: org.asynchttpclient.exception.RemotelyClosedException: Remotely closed at org.asynchttpclient.exception.RemotelyClosedException.INSTANCE(Unknown Source) INFO [TestNG-test=ATDTest-1] (AppiumParallelMethodTestListener.java:122)- Driver Session exisstsfalsenull INFO [TestNG-test=ATDTest-1] (SessionContext.java:25)- SessionContext default constructor INFO [TestNG-test=ATDTest-1] (SessionContext.java:51)- Using reportportal.properties file from src/test/resources/reportportal.properties INFO [TestNG-test=ATDTest-1] (SessionContext.java:57)- Loaded reportportal.properties file - /Users/lavanya.jk/IdeaProjects/QECC_Meetup/AppiumTestDistribution/src/test/resources/reportportal.properties INFO [TestNG-test=ATDTest-1] (SessionContext.java:29)- Initialized SessionContext INFO [TestNG-test=ATDTest-1] (SessionContext.java:42)- Removing context for thread - 27 com.appium.executor.CustomeListener.afterInvocation() was invoked FAILED: dragNDrop java.lang.IllegalArgumentException: Input must be set at org.openqa.selenium.internal.Require.nonNull(Require.java:60) at org.openqa.selenium.support.ui.FluentWait.(FluentWait.java:94) at org.openqa.selenium.support.ui.WebDriverWait.(WebDriverWait.java:74) at org.openqa.selenium.support.ui.WebDriverWait.(WebDriverWait.java:43) at com.test.site.UserBaseTest.waitForElement(UserBaseTest.java:26) at com.test.site.UserBaseTest.login(UserBaseTest.java:22) at com.test.site.SliderTest.dragNDrop(SliderTest.java:12) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:135) at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:673) at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:220) at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50) at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:945) at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:193) at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)

image

Please find the Browserstack appium logs -

Appium logs.txt

the .ipa file launches on browserstack successfully, but test case fails due to above mentioned exception.

Do you have an idea on this issue or how to resolve this. Thank you.

saikrishna321 commented 1 year ago

@LavanyaJK Can you add iosDeviceType=real to the server config

{
  "android": {
    "automationName": "UIAutomator2",
    "app": "bs://6b27ca8387cbd29e429f5fea9595edf8460eff60",
    "noSign": true,
    "browserstack.appium_version": "2.0.0",
    "project": "First TestNg Android Project",
    "build": "browserstack-1111",
    "name": "first_test",
    "browserstack.debug": true
  },
  "iOS": {
    "platformName": "iOS",
    "app": "bs://4e4e5743713d29a3599946e9949979cf9e20375f",
    "deviceName": "iPhone",
    "wdaLaunchTimeout": 80000,
    "wdaConnectionTimeout": 80000,
    "preventWDAAttachments": true,
    "clearSystemFiles": true,
    "shouldUseSingletonTestManager": false,
    "simpleIsVisibleCheck": true,
    "maxTypingFrequency": 10
  },
  "serverConfig" : {
    "server": {
      "use-plugins": ["device-farm"],
      "plugin": {
        "device-farm": {
          "platform": "iOS",
          "skipChromeDownload": true,
          "iosDeviceType": "real",
          "cloud":
            {
              "cloudName": "browserstack",
              "url": "http://hub-cloud.browserstack.com",
              "devices": [
                {
                  "deviceName": "Samsung Galaxy S22",
                  "os_version": "12.0",
                  "platform": "android"
                },
                {
                  "deviceName": "iPhone 11 Pro",
                  "os_version": "15",
                  "platform": "ios"
                }
              ]
            }
        }
      }
    }
  },
  "appiumServerPath": "./node_modules/appium/build/lib/main.js"
}
LavanyaJK commented 1 year ago

Hi @saikrishna321,

IOS case is running successfully on BrowserStack now.

Thank you so much.