Appium - WebView测试(Android)
来源:互联网 发布:近年来重庆物流数据 编辑:程序博客网 时间:2024/04/30 16:08
Appium - WebView测试(Android)
现在App都是混合型的,有原生的也包含WebView的,appium测试的时候就需要在原生和WebView之间切换才能完成测试。
1. 查看所有context
查看当前所有的窗口
- Set<String> contextNames = driver.getContextHandles();
- System.print(contextNames);
- [NATIVE_APP, WEBVIEW_com.test.android, WEBVIEW_com.estrongs.android.pop, WEBVIEW_com.xxxxx.sjj]
NATIVE_APP就是我的被测应用原生界面
WEBVIEW_com.test.android 是我的被测应用打开的WebView
另外两个一个是ES, 一个其他的应用(混合型的)
2.切换到WebView
通过上面方法获得当前的所有context
我们可以通过context方法切换到指定的应用
- <pre name="code" class="java">driver.context("WEBVIEW_com.test.android");
- driver.findElementByID("wd");
3. 切换到NativeApp
测试完web应用,需要操作原生应用的时候就需要切换回NATIVE_APP
我们可以通过context方法切换到原生应用
- <pre name="code" class="java">driver.context("NATIVE_APP");
4. Demo
- /**
- * Switch to NATIVE_APP or WEBVIEW
- * @param sWindow window name
- */
- private void switchToWindow(String sWindow) {
- LogManager.getLogger(this.getClass()).info("Swith to window: " + sWindow);
- Set<String> contextNames = driver.getContextHandles();
- LogManager.getLogger(this.getClass()).info("Exists windows: " + contextNames.toString());
- for (String contextName : contextNames) {
- if (contextName.contains(sWindow)) {
- driver.context(contextName);
- break;
- }
- }
- }
- switchToWindow("WEBVIEW_com.test.android");
- driver.findElementByID("wd").sendKeys("test");
- driver.findElementByID("sub").click();
- switchToWindow("NATIVE_APP");
0 0
- Appium - WebView测试(Android)
- Appium - WebView测试(Android)
- Appium - WebView测试(Android)
- appium webview H5 测试
- Appium 对于 Android 中webview 页面测试注意的问题
- appium-webview应用的测试
- appium(七)测试webview
- Android Appium自动化测试
- Appium自动化测试Android
- android appium测试
- RF+Appium 测试webview:用户注册
- Appium测试Android混合应用时,第二次切换到WebView时的定位问题
- Appium测试环境搭建-Android
- appium移动自动化测试---Android
- Appium+Python:Android自动化测试
- appium对于混合app的webview页面的测试
- Appium中开启iOS webview调试进行h5自动化测试
- appium测试微信公众号的WebView
- android中确定键重复点击,却只想在时间内,只显示点击一次
- 158.Two Strings Are Anagrams-两个字符串是变位词(容易题)
- Appium 基础概念
- 新开始,java基础小结
- android多进程通信的几种方式一
- Appium - WebView测试(Android)
- PAT How Long Does It Take (25) (拓扑排序)
- 原串翻转
- 数据结构学习记录-1
- 全局变量赋值问题
- 链表反转C++
- 指针中星号的位置问题
- java的System.getProperty()方法详解
- 代理模式的扩展