java appium webview切换处理

Posted testway

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java appium webview切换处理相关的知识,希望对你有一定的参考价值。

        Set<String> contexts = driver.getContextHandles();
        for(String item :contexts){
           // NATIVE_APP
            //WEBVIEW_com.xxx.xxxx
            System.out.println(item);
        }
        Set<String> contextNames = driver.getContextHandles();
        List<String> webViewContextNames =  contextNames
                .stream()
                .filter(contextName -> contextName.contains("WEBVIEW_"))
                .collect(Collectors.toList());
        String currentContextView = "";

        if (webViewContextNames.size() > 0){
            currentContextView = (String) webViewContextNames
                    .toArray()[webViewContextNames.size()-1];
            driver.context(currentContextView);
        }
driver.context(currentContextView); 
执行的是切换到最后一个webview

以上是关于java appium webview切换处理的主要内容,如果未能解决你的问题,请参考以下文章