【问题标题】:Appium breaking on switching to webviewAppium 在切换到 webview 时中断
【发布时间】:2016-07-28 16:27:18
【问题描述】:

我已经阅读了所有我能找到的东西,尝试了所有我想到的东西,但我仍然坚持这个问题。因此,在混合应用程序上工作时,它具有登录屏幕(完全原生),并带有一个打开 web 视图的按钮。在我切换到 Web 视图以尝试定位元素后,appium 刹车。有没有人有类似的问题?或者有什么建议或解决方案?

下面是相关代码:

public void randomTest() throws InterruptedException{

        driver.findElement(By.id("com.something.something:id/activate")).click(); //This is native part     

        Thread.sleep(3000);
        driver.context("WEBVIEW_com.something.something"); //here it brakes (and NOT EVERY time, sometimes it passes this point, but lets say once in 10 times it passes..)
        Thread.sleep(100);
        //Assert.assertTrue(driver.findElement(By.className("button")).isDisplayed());
}

Appium 报告设备不可见(adb 仍然可以看到) Appium 报告了这一点(以及其他内容):

Available contexts: 
[debug] ["WEBVIEW_com.something.something","WEBVIEW_com.something.something"
[debug] Available contexts:
NATIVE_APP,WEBVIEW_com.something.something,WEBVIEW_com.something.something
[debug] Connecting to chrome-backed webview
 value: { message: 'unknown error: Device KR7A3P92LS is not online\n  (Driver info: chromedriver=2.18.343845.......

然后在一堆其他东西之后,说:

Error: An unknown server-side error occurred while processing the command. (Original error: unknown error: Device KR7A3P92LS is not online

帮助? :)

【问题讨论】:

    标签: android webview appium


    【解决方案1】:

    原因:当 chromedriver 在切换到或从 webview 时无法访问并且 appium 一直在等待来自 chromedriver 的响应时,就会发生这种情况。

    解决方案:监控 chromedriver,当它挂起时将其杀死/重新启动。

    详细答案请访问:Appium (v1.4.16.1), Switch to WebView fails when i try a second time

    【讨论】:

    • 嗯,是的,这就是我从 appium 报告中读到的内容,我尝试过您之前建议我的方法,但对我不起作用..'code' ChromedriverHandler.chromeDriverHandlerThread().stop (); 'code' 方法被剥夺.. 当你实际使用它们时,它会报告有关线程的错误:'code' 线程“Thread-0”中的异常 java.lang.NoClassDefFoundError: org/json/JSONObject 'code' 虽然它仍然有效(有那个错误),不做改变,测试在我试图切换到webview的时候再次失败。但感谢您的回答。 :)
    • @BojanAntić:很抱歉没有让您了解依赖项:您需要将这些添加到您的项目中:apache 的 httpclient-4.3.1.jar、httpcore-4.3.jar 和 json 简单 jar:json- 20080701.jar 和 .stop() 只是发出警告,它不会阻止你执行。请试试这个,如果它对你有帮助,请告诉我。谢谢
    • 是的,我已经有了这些,但 appium 仍然失败。最糟糕的部分是我无法弄清楚失败的模式。我虽然在我启动 appium 后它总是会设法切换到 webview,下一个是 if'y .. 但是他们,我刚刚启动 appium,然后继续第一次测试他没有设法切换上下文。虽然即使每次我计划运行测试时都必须重新启动 appium 也不好,因为它们应该通过 jenkins 在远程服务器上运行。
    • 如果您的 appium 服务器和 chromedriver 在某个远程机器上运行 那么您需要在同一台服务器上运行代码 ChromedriverHandler.chromeDriverHandlerThread().start()。试试这个,让我知道,同时将日志粘贴为 gist。
    • 是的,BeforeTest 中的 start() 和 afterTest() 中的 stop()
    猜你喜欢
    • 2021-01-10
    • 2016-06-13
    • 2014-07-11
    • 1970-01-01
    • 2015-09-16
    • 2020-08-17
    • 2016-05-08
    • 1970-01-01
    • 2021-07-20
    相关资源
    最近更新 更多