zebrunner / appium

Enhanced Appium for Elastic Selenium Grid/MCloud services
9 stars 3 forks source link

unable to register driver session via agent when invalid `capabilities.adbExecTimeout=90000[` capability provided #345

Closed vdelendik closed 5 months ago

vdelendik commented 8 months ago

after providing mistakenly capabilities.adbExecTimeout=90000[ capability with square bracket session can't be started.... but the problem is that our reporting agent crash test execution earlier:

18:24:06  2024-02-27 17:24:05 Messager [TestNG-test=Acceptance Proxy-1-79] [ERROR] TEST [Acceptance Proxy - setProfilePinElementsTest] SKIPPED at [17:24:05 2024-02-27] - Could not register start of the test session.
18:24:06  Response status code: 403.
18:24:06  Raw response body: 
18:24:06  {"requestId":"0987f65f553461f9","code":"REP-2322","message":"Test session with session id '0b996e16-3924-4a60-b678-49f9ec1cea31' already exists."}
18:24:06  
18:24:06  com.zebrunner.agent.core.registrar.UnirestZebrunnerApiClient.throwServerException(UnirestZebrunnerApiClient.java:98)
18:24:06  com.zebrunner.agent.core.registrar.UnirestZebrunnerApiClient.lambda$startSession$41(UnirestZebrunnerApiClient.java:387)
18:24:06  kong.unirest.BaseResponse.ifFailure(BaseResponse.java:113)
18:24:06  com.zebrunner.agent.core.registrar.UnirestZebrunnerApiClient.lambda$startSession$42(UnirestZebrunnerApiClient.java:387)
18:24:06  com.zebrunner.agent.core.registrar.UnirestZebrunnerApiClient.lambda$sendRequest$1(UnirestZebrunnerApiClient.java:104)
18:24:06  com.zebrunner.agent.core.registrar.RetryUtils.tryInvoke(RetryUtils.java:15)
18:24:06  com.zebrunner.agent.core.registrar.UnirestZebrunnerApiClient.sendRequest(UnirestZebrunnerApiClient.java:103)
18:24:06  com.zebrunner.agent.core.registrar.UnirestZebrunnerApiClient.startSession(UnirestZebrunnerApiClient.java:382)
18:24:06  com.zebrunner.agent.core.registrar.SessionRegistrar.registerStart(SessionRegistrar.java:45)
18:24:06  com.zebrunner.agent.core.webdriver.StartSessionInterceptor.onSessionStart(StartSessionInterceptor.java:71)
18:24:06  io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java)
18:24:06  org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:157)
18:24:06  io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:80)
18:24:06  io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:107)
18:24:06  com.zebrunner.carina.webdriver.core.factory.impl.MobileFactory.create(MobileFactory.java:135)
18:24:06  com.zebrunner.carina.webdriver.core.factory.DriverFactory.create(DriverFactory.java:90)
18:24:06  com.zebrunner.carina.webdriver.IDriverPool.createDriver(IDriverPool.java:364)
18:24:06  com.zebrunner.carina.webdriver.IDriverPool.getDriver(IDriverPool.java:117)
18:24:06  com.zebrunner.carina.webdriver.IDriverPool.getDriver(IDriverPool.java:80)
18:24:06  com.zebrunner.carina.webdriver.IDriverPool.getDriver(IDriverPool.java:68)
18:24:06  com.zebrunner.carina.utils.android.IAndroidUtils.executeShell(IAndroidUtils.java:843)
18:24:06  com.zebrunner.carina.utils.android.IAndroidUtils.executeShell(IAndroidUtils.java:822)
18:24:06  com.zebrunner.carina.utils.android.IAndroidUtils.getAppVersionName(IAndroidUtils.java:978)
...

potentially RetryUtils in reporting agent might be a reason. let's first of all repro on dev env and debug...

vavadikb commented 8 months ago

reproduced the connection to the appium via the emulator with the erroneous capability adbExecTimeout=90000[ without agents

when appium sees an incorrect capability, it forwards [HTTP] <-- POST /session 500 and does not allow a new session to be created and throws an error in the form [AppiumDriver@b587] Encountered internal error running command: Error: in this case adds details 'adbExecTimeout' must be of type number

full log

[AppiumDriver@b587] Calling AppiumDriver.createSession() with args: [{"app":"/Users/vadimbabaiev/Downloads/carinademoexample.apk","adbExecTimeout":"90000[","platformVersion":"14.0","automationName":"UiAutomator2","platformName":"Android","deviceName":"Pixel 4 API 34"},null,{"firstMatch":[{"appium:adbExecTimeout":"90000[","appium:app":"/Users/vadimbabaiev/Downloads/carinademoexample.apk","appium:automationName":"UiAutomator2","appium:deviceName":"Pixel 4 API 34","platformName":"android","appium:platformVersion":"14.0"}]}]
[AppiumDriver@b587] Event 'newSessionRequested' logged at 1709215917515 (15:11:57 GMT+0100 (Central European Standard Time))
[Appium] Attempting to find matching driver for automationName 'UiAutomator2' and platformName 'android'
[Appium] The 'uiautomator2' driver was installed and matched caps.
[Appium] Will require it at /Users/vadimbabaiev/.appium/node_modules/appium-uiautomator2-driver
[Appium] Requiring driver at /Users/vadimbabaiev/.appium/node_modules/appium-uiautomator2-driver/build/index.js
[AppiumDriver@b587] Appium v2.4.1 creating new AndroidUiautomator2Driver (v2.44.0) session
[AppiumDriver@b587] Checking BaseDriver versions for Appium and AndroidUiautomator2Driver
[AppiumDriver@b587] Appium's BaseDriver version is 9.5.0
[AppiumDriver@b587] AndroidUiautomator2Driver's BaseDriver version is 9.5.0
[AndroidUiautomator2Driver@4564] Creating session with W3C capabilities: {
[AndroidUiautomator2Driver@4564]   "alwaysMatch": {
[AndroidUiautomator2Driver@4564]     "platformName": "android",
[AndroidUiautomator2Driver@4564]     "appium:adbExecTimeout": "90000[",
[AndroidUiautomator2Driver@4564]     "appium:app": "/Users/vadimbabaiev/Downloads/carinademoexample.apk",
[AndroidUiautomator2Driver@4564]     "appium:automationName": "UiAutomator2",
[AndroidUiautomator2Driver@4564]     "appium:deviceName": "Pixel 4 API 34",
[AndroidUiautomator2Driver@4564]     "appium:platformVersion": "14.0"
[AndroidUiautomator2Driver@4564]   },
[AndroidUiautomator2Driver@4564]   "firstMatch": [
[AndroidUiautomator2Driver@4564]     {}
[AndroidUiautomator2Driver@4564]   ]
[AndroidUiautomator2Driver@4564] }
[AndroidUiautomator2Driver@4564] Deleting UiAutomator2 session
[AndroidUiautomator2Driver@4564] Unable to stop ChromeDriver proxies: Cannot read properties of undefined (reading 'proxyReqRes')
[AppiumDriver@b587] Event 'newSessionStarted' logged at 1709215917530 (15:11:57 GMT+0100 (Central European Standard Time))
[AppiumDriver@b587] Encountered internal error running command: SessionNotCreatedError: A new session could not be created. Details: 'adbExecTimeout' must be of type number
[AppiumDriver@b587]     at AndroidUiautomator2Driver.createSession (/usr/local/lib/node_modules/appium/node_modules/@appium/base-driver/lib/basedriver/driver.ts:272:13)
[AppiumDriver@b587]     at AndroidUiautomator2Driver.createSession (/Users/vadimbabaiev/.appium/node_modules/appium-uiautomator2-driver/lib/driver.ts:346:75)
[AppiumDriver@b587]     at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:717:56)
[HTTP] <-- POST /session 500 18 ms - 644
[HTTP] 
vdelendik commented 5 months ago

closing as won't fix. backend appium logs contains exact reason:

[AppiumDriver@b587] Encountered internal error running command: SessionNotCreatedError: A new session could not be created. Details: 'adbExecTimeout' must be of type number

so user can read and identify root cause.