appium移动自动化中的上下文切换问题

时间:2017-05-21 17:14:08

标签: mobile automation appium

您好我尝试在移动自动化中从原生页面切换到混合页面。它抛出一个错误铬驱动程序已经在使用中。如何在移动自动化中修复它。

1 个答案:

答案 0 :(得分:0)

如果您需要使用java自动化Android应用程序,可以使用以下方法在上下文之间切换。

public final String WEBVIEW = "WEBVIEW_com.maxsoft.testextractor";
public final String NATIVE_APP = "NATIVE_APP";

public void switchContextTo(String context){
        if (context.toLowerCase().equals(WEBVIEW.toLowerCase())) {
            androidDriver.context(WEBVIEW); // set context to WEBVIEW_1
        } else {
            androidDriver.context(NATIVE_APP); // set context to NATIVE_APP
        }
    }