Appium (v1.4.16.1), Switch to WebView fails when i

2019-07-13 18:31发布

Appium (v1.4.16.1), Switch to WebView fails when I try to switch to webview second time. Is there something I should be considering?

Please refer to the below use case using Appium on Android-

  1. Launch Android Device > Perform some actions
  2. Switch context = WebView_1 > Perform some actions
  3. Switch context = Native_App
  4. Switch context = WebView_1 > Perform some actions

In Step#2 and Step#4, it is the same WebView_1, but the content is different. Say: step#2 opened html-1 and step#4 opened html-2.

Problem: I am unable to switch context in Step#4.

.... below are some logs of the error

info: [debug] Available contexts: NATIVE_APP,WEBVIEW_1 info: [debug] Connecting to chrome-backed webview info: [debug] Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command. (Original error: We already have a chromedriver instance running)","origValue":"We already have a chromedriver instance running"},"sessionId":"38904ff5-928a-4dc0-ac8a-c7bc5f6504e4"}

2条回答
成全新的幸福
2楼-- · 2019-07-13 18:48

I got exactly the same error when I created a second instance of the Selenium WebDriver / RemoteWebDriver and tried to connect to the Appium server without accurately shutting down the first instance. Appium is a bit pernickety in this respect.

查看更多
做自己的国王
3楼-- · 2019-07-13 18:58

switching to webview and then to native_app causes problem sproadically in appium, I had the same problem and after researching I found out that on switching to webview, chromedriver sometimes, becomes unresponsive and appium waits for chromedriver until the timeout defined for appium and thus these problem occurs, how to fix this: Create a thread to monitor chromedriver, when it hangs, restarts chromedriver.

Readymade solution: Download chromedriverhandler.jar from https://github.com/mi2pankaj/chromeDriverHandler, add to your project,

use this in beforeTest/beforeClass or at the start of your test: ChromedriverHandler.chromeDriverHandlerThread().start();

use this in afterTest/afterClass or at the end of your test: ChromedriverHandler.chromeDriverHandlerThread().stop();

Note: you may need to add these to your project: apache's httpclient-4.3.1.jar, httpcore-4.3.jar and json simple jar: json-20080701.jar

Hope this helps.

查看更多
登录 后发表回答