Appium (v1.4.16.1),当我第二次尝试时切换到 WebView 失败 [英] Appium (v1.4.16.1), Switch to WebView fails when i try a second time

查看:27
本文介绍了Appium (v1.4.16.1),当我第二次尝试时切换到 WebView 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Appium (v1.4.16.1),当我尝试第二次切换到 webview 时切换到 WebView 失败.有什么我应该考虑的吗?

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?

请参考以下在 Android 上使用 Appium 的用例-

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

  1. 启动 Android 设备 > 执行一些操作
  2. 切换上下文 = WebView_1 > 执行一些操作
  3. 切换上下文 = Native_App
  4. 切换上下文 = WebView_1 > 执行一些操作

在Step#2和Step#4中,是同一个WebView_1,但是内容不同.说:step#2 打开 html-1,step#4 打开 html-2.

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.

问题:我无法在步骤#4 中切换上下文.

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

.... 下面是一些错误日志

.... below are some logs of the error

信息:[调试] 可用上下文:NATIVE_APP,WEBVIEW_1信息:[调试] 连接到支持 chrome 的 webviewinfo: [debug] Responding to client with error: {"status":13,"value":{"message":"处理命令时发生未知的服务器端错误.(原始错误:我们已经有一个 chromedriver 实例running)","origValue":"我们已经有一个 chromedriver 实例正在运行"},"sessionId":"38904ff5-928a-4dc0-ac8a-c7bc5f6504e4"}

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

推荐答案

切换到 webview 然后到 native_app 导致 appium 中的问题,我遇到了同样的问题,经过研究我发现切换到 webview 时,chromedriver 有时,变得无响应并且 appium 等待 chromedriver 直到为 appium 定义的超时,因此出现这些问题,如何解决这个问题:创建一个线程来监控 chromedriver,当它挂起时,重新启动 chromedriver.

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.

现成的解决方案:从 https://github.com/mi2pankaj/chromeDriverHandler 下载 chromedriverhandler.jar,添加到您的项目中,

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

在 beforeTest/beforeClass 或在你的测试开始时使用它:ChromedriverHandler.chromeDriverHandlerThread().start();

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

在 afterTest/afterClass 或测试结束时使用它:ChromedriverHandler.chromeDriverHandlerThread().stop();

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

注意:您可能需要将这些添加到您的项目中:apache 的 httpclient-4.3.1.jar、httpcore-4.3.jar 和 json simple jar:json-20080701.jar

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

希望这会有所帮助.

这篇关于Appium (v1.4.16.1),当我第二次尝试时切换到 WebView 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆