Appium (v1.4.16.1), Switch to WebView fails when i try a second time

*爱你&永不变心* 提交于 2019-12-24 00:16:33

问题


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"}


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/35115151/appium-v1-4-16-1-switch-to-webview-fails-when-i-try-a-second-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!