问题描述
限时送ChatGPT账号..我使用的是 appium 1.4.16 和 Android 6 智能手机.
I'm using appium 1.4.16 and smartphone with Android 6.
运行此代码:
public boolean fluentWaitChangeContext(String context, int timeout) {
Wait wait = new FluentWait(driver)
.withTimeout(timeout, TimeUnit.SECONDS)
.pollingEvery(5, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class, NoSuchContextException.class);
boolean isFound = false;
try {
wait.until(input -> {
if (driver.getContextHandles().size() == 2) {
driver.context(context);
// driver.context(driver.getContextHandles().toArray()[1].toString());
return true;
}
return null;
});
} catch (org.openqa.selenium.TimeoutException exc) {
}
return isFound;
}
要切换到 webview 上下文,
To switch to a webview context,
抛出chrome无法访问"错误.
Throws "chrome not reachable" error.
开关很少起作用.
我用谷歌搜索但可以解决它.chrome无法访问"你知道哪些常见的解决方法
I googled but could fix it. What common solution do you know for "chrome not reachable"
info: [debug] returning process name: com.ridewith
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_undefined
info: [debug] ["WEBVIEW_com.ridewith"]
info: [debug] Available contexts: NATIVE_APP,WEBVIEW_com.ridewith
info: [debug] Connecting to chrome-backed webview
info: Chromedriver: Changed state to 'starting'
info: Chromedriver: Set chromedriver binary as: /Users/eladb/.npm-packages/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver
info: Chromedriver: Killing any old chromedrivers, running: ps -ef | grep /Users/eladb/.npm-packages/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver | grep -v grep |grep -e '--port=9515\(\s.*\)\?$' | awk '{ print $2 }' | xargs kill -15
info: Chromedriver: Successfully cleaned up old chromedrivers
info: Chromedriver: Spawning chromedriver with: /Users/eladb/.npm-packages/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver/mac/chromedriver --url-base=wd/hub --port=9515
info: Chromedriver: [STDOUT] Starting ChromeDriver 2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281) on port 9515
Only local connections are allowed.
info: JSONWP Proxy: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: JSONWP Proxy: Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Mac OS X\",\"version\":\"10.11.2\"}}}"
info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.ridewith","androidUseRunningApp":true,"androidDeviceSerial":"ZX1G425VDZ"}}}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"4d6fe365883b68ea3847ea62c78d6de3","status":13,"value":{"message":"unknown error: Device ZX1G425VDZ is not online\n (Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19...
info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.ridewith","androidUseRunningApp":true,"androidDeviceSerial":"ZX1G425VDZ"}}}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"ac2dfd0e9d586348bdb247433286590e","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281),platform=M...
info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.ridewith","androidUseRunningApp":true,"androidDeviceSerial":"ZX1G425VDZ"}}}
info: [debug] [BOOTSTRAP] [debug] Emitting system alert message
info: [debug] Emitting alert message...
info: JSONWP Proxy: Got response with status 200: {"sessionId":"974a95bde40483689bb537c23d0a0a8d","status":100,"value":{"message":"chrome not reachable\n (Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19e85787ced4281),platform=M...
info: JSONWP Proxy: Proxying [POST /session] to [POST http://127.0.0.1:9515/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.ridewith","androidUseRunningApp":true,"androidDeviceSerial":"ZX1G425VDZ"}}}
info: JSONWP Proxy: Got response with status 200: {"sessionId":"5a5f42437c86db7056dbfbb28c532a77","status":13,"value":{"message":"unknown error: Device ZX1G425VDZ is not online\n (Driver info: chromedriver=2.18.343837 (52eb4041461e46a6b73308ebb19...
error: Chromedriver: Chromedriver exited unexpectedly with code null, signal SIGTERM
推荐答案
我可以通过在测试执行期间一直监控 chromedriver 来解决这个问题,chromedriver 在从 natiove_app 切换回 webview 时变得无响应.我在 https://github/mi2pankaj/chromeDriverHandler 上开发了一小段代码,它有解决了我的所有问题,只需将此 jar chromedriverHandler.jar 添加到您的项目中并使用 ChromedriverHandler.chromeDriverHandlerThread().start();在你的@beforeclass/@beforetest 和 ChromedriverHandler.chromeDriverHandlerThread().stop();在你的@afterclass/@aftertest 中.
I could get a fix by monitoring chromedriver all the time during test execution, chromedriver becomes unresponsive while switching back to webview from natiove_app. I developed a small piece of code available at https://github/mi2pankaj/chromeDriverHandler, it has solved my all problems, just add this jar chromedriverHandler.jar to your project and use ChromedriverHandler.chromeDriverHandlerThread().start(); in your @beforeclass / @beforetest and ChromedriverHandler.chromeDriverHandlerThread().stop(); in your @afterclass / @aftertest.
这篇关于Appium抛出“chrome无法访问"切换上下文时偶尔会出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论