Encounter "Unable to create a new remote session" from the second test case when running the Test Suite on Kobiton device

Environment: Windows 10 version 1809, Appium 1.8.1, JDK 1.8.231, Node 12.13.1

Scenario: Execute the test suite (at least two test cases in that) for Web Testing on Mobile Browser, using Kobiton Device

Actual result: The first test is executed successfully, but failed from the second, here is the log details

    2019-12-16 17:14:50.579 INFO  k.k.c.m.CustomKeywordDelegatingMetaClass - utilHelpers.BrowserHp.closeBrowser is PASSED
2019-12-16 17:14:52.599 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/LoginPage/LoginDefaultUI_876
2019-12-16 17:14:52.603 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2019-12-16 17:14:52.603 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/HomePage/HomePageDefaultUI_880
Test Cases/HomePage/HomePageDefaultUI_880
[:]
2019-12-16 17:14:52.614 INFO  c.k.k.core.webui.driver.DriverFactory    - Starting 'Kobiton Device' driver
2019-12-16 17:14:52.615 INFO  c.k.k.c.w.util.WebDriverPropertyUtil     - User set preference: ['acceptSslCerts', 'true']
2019-12-16 17:14:52.615 INFO  c.k.k.c.w.util.WebDriverPropertyUtil     - User set preference: ['sessionDescription', '']
2019-12-16 17:14:52.616 INFO  c.k.k.c.w.util.WebDriverPropertyUtil     - User set preference: ['platformVersion', '7.0']
2019-12-16 17:14:52.616 INFO  c.k.k.c.w.util.WebDriverPropertyUtil     - User set preference: ['sessionName', 'Automation test session']
2019-12-16 17:14:52.616 INFO  c.k.k.c.w.util.WebDriverPropertyUtil     - User set preference: ['captureSreenShots', 'true']
2019-12-16 17:14:52.616 INFO  c.k.k.c.w.util.WebDriverPropertyUtil     - User set preference: ['browserName', 'chrome']
2019-12-16 17:14:52.616 INFO  c.k.k.c.w.util.WebDriverPropertyUtil     - User set preference: ['deviceOrientation', 'portrait']
2019-12-16 17:14:52.616 INFO  c.k.k.c.w.util.WebDriverPropertyUtil     - User set preference: ['platformName', 'Android']
2019-12-16 17:14:52.616 INFO  c.k.k.c.w.util.WebDriverPropertyUtil     - User set preference: ['deviceName', 'Galaxy Note5']
2019-12-16 17:14:52.617 INFO  c.k.k.core.webui.driver.DriverFactory    - Connecting to remote web server 'http://my.chau:f2bc3233-a184-4e9d-ae53-5ee5d06a1b57@api.kobiton.com/wd/hub' with type 'Appium'
2019-12-16 17:14:53.656 ERROR c.k.k.core.keyword.internal.KeywordMain  - ❌ Unable to open browser with url: 'https://medscomm-web-ea-staging.azurewebsites.net/' (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to open browser with url: 'https://medscomm-web-ea-staging.azurewebsites.net/'
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
	at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword.openBrowser(OpenBrowserKeyword.groovy:81)
	at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword.execute(OpenBrowserKeyword.groovy:67)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.openBrowser(WebUiBuiltInKeywords.groovy:60)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$openBrowser.call(Unknown Source)
	at utilHelpers.BrowserHp.openBrowserWithUrl(BrowserHp.groovy:11)
	at utilHelpers.BrowserHp.invokeMethod(BrowserHp.groovy)
	at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
	at NewTestListener.sampleBeforeTestCase(NewTestListener.groovy:26)
	at NewTestListener.invokeMethod(NewTestListener.groovy)
	at com.kms.katalon.core.context.internal.TestHooker.invokeMethod(TestHooker.java:109)
	at com.kms.katalon.core.context.internal.TestHooker.lambda$3(TestHooker.java:93)
	at com.kms.katalon.core.context.internal.TestHooker.invokeContextMethods(TestHooker.java:92)
	at com.kms.katalon.core.context.internal.TestListenerCollector.lambda$3(TestListenerCollector.java:86)
	at com.kms.katalon.core.context.internal.TestListenerCollector.handleListenerEvent(TestListenerCollector.java:83)
	at com.kms.katalon.core.context.internal.ExecutionEventManager.publicEvent(ExecutionEventManager.java:36)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:219)
	at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:133)
	at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:116)
	at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:83)
	at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
	at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
	at TempTestSuite1576491203548.run(TempTestSuite1576491203548.groovy:35)
Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: No device matching the desired capabilities
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'CTHMY-1', ip: '192.168.90.130', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: SwipeableAndroidDriver
remote stacktrace: 
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'CTHMY-1', ip: '192.168.90.130', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: SwipeableAndroidDriver
	at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:208)
	at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:217)
	at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
	at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
	at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
	at com.kms.katalon.core.appium.driver.SwipeableAndroidDriver.execute(SwipeableAndroidDriver.java:1)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
	at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)
	at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:84)
	at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:85)
	at com.kms.katalon.core.appium.driver.SwipeableAndroidDriver.<init>(SwipeableAndroidDriver.java:24)
	at com.kms.katalon.core.webui.driver.DriverFactory.createNewRemoteWebDriver(DriverFactory.java:338)
	at com.kms.katalon.core.webui.driver.DriverFactory.startNewBrowser(DriverFactory.java:250)
	at com.kms.katalon.core.webui.driver.DriverFactory.openWebDriver(DriverFactory.java:191)
	at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword$_openBrowser_closure1.doCall(OpenBrowserKeyword.groovy:74)
	at com.kms.katalon.core.webui.keyword.builtin.OpenBrowserKeyword$_openBrowser_closure1.call(OpenBrowserKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	... 23 more
Caused by: java.lang.reflect.InvocationTargetException
	at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:186)
	... 42 more
Caused by: org.openqa.selenium.SessionNotCreatedException: No device matching the desired capabilities
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'CTHMY-1', ip: '192.168.90.130', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: SwipeableAndroidDriver
remote stacktrace: 
	at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
	at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
	at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
	at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
	... 43 more
)

The root cause is here:

Caused by: org.openqa.selenium.SessionNotCreatedException: No device matching the desired capabilities
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'CTHMY-1', ip: '192.168.90.130', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'

It means the device is using another session. You should wait for the device available then start again.

Thanks

1 Like

Hi @duyluong,

I have added two desired capabilities as below and also add WebUI.delay(10) before each test case, but still get the same issue. Could you provide more details how to wait for the device available?

Hi @cthmy.ctu,

If you want to run with Kobiton devices via Remote execution, you need to provide more desired capabilities that describes in Automation Settings of each Kobiton device.

We also recommend you to use Kobiton plugin in our store (https://store.katalon.com/product/137/Kobiton-Integration) that provides an easier way to select device and fully integrate with Kobiton.

Thanks

I was successful by using Thread.sleep(120000) without any desired mobile capability before each test case to wait until device backs to Online and ready. I am wondering is there any way to wait for Device status is Online?

If you have any idea for it, please let me know.

Thanks

Hi @duyluong,

The same problem happens to me on both Remote server and Kobiton Plugin options. Here the steps I tried

  1. create a project from Web Sample project of Katalon
  2. Run with Remote server using the same suggested Kobiton device capabilities, even add more for waiting device ready
  3. Run with Kobiton Plugin as Katalon docs

    But on the second case, exception “No device matching the desired capabilities” ALWAYS SHOW for both step 2 and 3

We did try to add Thread.sleep but the 2nd test case can only run when using Thread.sleep(90000) as at least.

As you can see in the picture,

  • Testcase Setup takes 138.5s
    • Thread.sleep(90000)
    • connect to Remote server command takes 48.5s
  • Testcase TearDown takes 2.1s

So the actual testcase running is just 24.5s, about 15% testcase running time and almost 75% time for connecting to device which is definitely UNACCEPTABLE for us

The issue does not occur on local real device or simulator so I assume that is Kobiton issue.

For now, I am using trial version for investigating but if this issue cannot go away in the near future, obviously we cannot consider to use the license one in our project either.
So it would be great if you can help check and response to me before my trial expire(next 10 days). The code and log are attached for your review and feel free to contact if need more information.
20191225_101231_nodelay.zip (1.5 MB)
20191225_100058_delay90s.zip (13.4 KB)

Thanks,
Anh Pham

Hi @ptvanh,

When starting a session, Kobiton will check your favorite devices that’s not utilizing to start. If the device is in use, you cannot start the session.
A session starts with openBrowser keyword and ends with closeBrowser keyword. You can get through this by using navigateToUrl instead of using openBrowser and closeBrowser. That solution will help you to run all test cases in one Kobiton session.

An another option is upgrading your Kobiton device plans to get access more available devices in Kobiton.

Thanks

Hi @duyluong,

Thanks for your explain.

First, I do agree that the root cause is device still in-use for about 1 mins even after finished session by closeBrowser command, that’s why next session cannot be started at openBrowser command. As my experience, it is too long to wait device ready in more than 1 mins so I assume this is Kobiton connecting device problem.

Second, I don’t think using navigateToUrl solution is gonna work because

  1. cannot use navigateToUrl without openBrowser command
    navigateToURLOnly
    navigateURLOnly.zip (7.6 KB)
  1. even work around with navigateToUrl for setupTestcase and 1 openBrowser on setup, there no error “No device …” but the user sessionID (login state) will be keeping for all running testcases, which causes the problem when cached and cookies is impact to the next cases.
    Always open new browser(clean state) is a good practice for automation web
    openBrowser1TimeInTestsuite
    openBrowser1TimeInSuite.zip (231.2 KB)

Again, we cannot suggest customer to upgrading Kobiton devices until this problem is resolved. And I am not sure we have enough trial time for the next trying, so please help check if any way to overcome this.

Thanks,
Anh Pham

1 Like