Appium-发现现有的Chromedriver用于上下文;使用它



我正在尝试自动化一个混合应用程序,在该应用程序中我不断地在网络和本机视图之间切换。

我使用的功能是

public void switchToWebContext() throws InterruptedException {
    Set<String> contextNames = appiumDriver.getContextHandles();
    for (String context : contextNames) {
        System.out.println("Context is" + context);
        if (context.contains("WEBVIEW")) {
            getAppiumWebDriver().context(context);
            displayLog("Mobile Web View switched");
        }
    }
}
public void switchToNativeContext() {
    Set<String> contextNames = getAppiumWebDriver().getContextHandles();
    for (String context : contextNames) {
        if (context.contains("NATIVE")) {
            displayLog("Native View found");
            getAppiumWebDriver().context(context);
        }
    }
}

我的问题是,导航首次正确进行流动,但在第二回合中,我得到了此错误

Found existing chromedriver for context

等待几分钟后,我得到的错误是

    [debug] [JSONWP Proxy] Proxying [GET /url] to [GET http://127.0.0.1:8000/wd/hub/session/ad84071a45fc33c30541cc85681dab7b/url] with no body
[debug] [AndroidDriver] ChromeDriver is not associated with a window. Re-initializing the session.
[Chromedriver] Restarting chromedriver
[debug] [Chromedriver] Changed state to 'restarting'
[debug] [JSONWP Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8000/wd/hub/session/ad84071a45fc33c30541cc85681dab7b] with no body

有人可以帮我吗?有什么方法可以使用现有上下文或以某种方式存储它以供将来使用

我在Windows 10上有趣的Appium 1.6.5

您不需要在Web_veiw和本机之间切换。最新的UIAUTomator对这两种观点都有内置的支持。只需从PlayStore更新设备的" Android System WebView",然后更新您的Android SDK即可。您的代码应在不在视图之间切换的情况下运行。

最新更新