mobile - 如何实现appium移动端新特性:getContexts for android混合自动化
问题描述
Appium 引入了一项使用移动命令收集 webview 详细信息的功能mobile:getContexts
。使用此功能,我想从 webview 中排除分离的窗口,以便我可以切换到实际需要的窗口。我如何在java中做到这一点?我如何过滤响应driver.executeScript("mobile:getContexts")
并验证 key 的值attached
。谢谢你。
解决方案
请使用以下方法获取最新的 appium v1.22+,
//getContext
String currentContext = (String) appiumDriver.execute(DriverCommand.GET_CURRENT_CONTEXT_HANDLE).getValue();
System.out.println("getContext:"+currentContext);
//SwithToContext (NATIVE_APP)
appiumDriver.execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", "NATIVE_APP"));
//SwithToContext (WEBVIEW)
appiumDriver.execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", "WEBVIEW"));
推荐阅读
- node.js - 对于 Node.js 项目中的所有子文件夹,对 require 使用全局自定义入口点
- python - 无法将 int 字符串转换为 chr 字符串
- c - pthread_create 使用 85MB VIRT 而不是 8MB VIRT
- spring-boot - 无法在带参数的获取请求中发送外部获取请求
- email - 如何在 Mailchimp 联系人中保存 200 多个自定义合并字段
- javascript - 如何修复 discord.js 禁止命令?
- python - Python - 使 GUI 链接到登录 webscraper
- vba - 我正在尝试在访问前端实现后期绑定,但无法让 DAO 参考工作
- javascript - javascript函数中的多个参数
- r - R shinydashboard - 根据用户的输入过滤数据