首页 > 移动平台 > 详细

java appium webview切换处理

时间:2018-07-12 17:11:22      阅读:218      评论:0      收藏:0      [点我收藏+]
        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切换处理

原文:https://www.cnblogs.com/testway/p/9300426.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!