码迷,mamicode.com
首页 > 移动开发 > 详细

java appium webview切换处理

时间:2018-07-12 17:58:04      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:handle   system   contains   cto   filter   native   list()   ati   text   

        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切换处理

标签:handle   system   contains   cto   filter   native   list()   ati   text   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!