java - UnsupportedCommandException:使用 Appium 的混合 Android 应用程序尚未实现方法错误
问题描述
我正在使用 Appium 为混合 Android 应用程序编写自动化测试用例。我正在使用下面的代码行将光标设置在下拉/弹出窗口上:
Set<String> stringSet = webDriver.getWindowHandles();
但是,这会产生以下错误:
org.openqa.selenium.UnsupportedCommandException: Method has not yet been implemented.
webdriver是AppiumDriver的对象。
这是一个混合(Cordova)移动应用程序。
我的堆栈跟踪:
Apr 03, 2019 4:20:21 PM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '404' -> incorrect JSON status mapping for 'unknown method' (405 expected)
org.openqa.selenium.UnsupportedCommandException: Method has not yet been implemented
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'VIKSHAH-M-F1AR', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.3', java.version: '1.8.0_152-release'
Driver info: io.appium.java_client.AppiumDriver
更新:更新 JDK 后
Apr 10, 2019 12:47:45 PM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '404' -> incorrect JSON status mapping for 'unknown method' (405 expected)
org.openqa.selenium.UnsupportedCommandException: Method has not yet been implemented
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'VIKSHAH2-M-F1AR', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.3', java.version: '1.8.0_202'
Driver info: io.appium.java_client.android.AndroidDriver
有没有人遇到过类似的问题?有没有其他方法可以使用 Appium 测试下拉?
解决方案
下面是我用来从可用上下文切换到第一个 Web 视图(非本机视图)的代码。如果您不确定上下文文本实际包含什么,请编写代码来捕获数组并显示所有值。
@Nullable
private String getWebContext() {
ArrayList<String> contexts = new ArrayList<String>(driver.getContextHandles());
for (String context : contexts) {
if (!context.equals("NATIVE_APP")) {
return context;
}
}
return null;
}
推荐阅读
- javascript - 从另一个目录操作 HTML 元素
- ios - 如何检测何时使用 gdb (iOS) 调试应用程序
- angular - 将支付图标库中的图像导入 Angular 的可扩展方式
- android - 用多个按钮做一件事?
- java - 如何在客户支持的角度为不同的用户组在后台进行票证限制?
- python - Time.sleep() 在循环内无法正常工作
- amazon-web-services - cfn-init 用于 cloudformation 启动模板
- python - pandas 函数基于 dict 创建组合列
- sql - CTE - 获取父级
- python-3.x - 解析二维列表并返回列表的值