【问题标题】:UnsupportedCommandException: Method has not yet been implemented error with hybrid Android app using AppiumUnsupportedCommandException:使用 Appium 的混合 Android 应用程序尚未实现方法错误
【发布时间】:2019-08-24 22:02:45
【问题描述】:

我正在使用 Appium 为混合 Android 应用编写自动化测试用例。 我正在使用下面的代码行将光标设置在下拉/弹出窗口上:

Set<String> stringSet =  webDriver.getWindowHandles();

但是,这会产生以下错误:

org.openqa.selenium.UnsupportedCommandException: Method has not yet been implemented.

webdriverAppiumDriver 的对象。

这是一个混合(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 测试下拉菜单?

【问题讨论】:

  • getWindowHandles() 通常用于传统的网络浏览器。我想不出任何理由将它与 Appium 驱动程序一起使用。也许您的意思是使用 getContextHandles()?
  • 原始发帖人对他自己的问题没有反应,但这个问题却成功地登上了 Stack Overflow 时事通讯。如果可以,我会再次投反对票。
  • @BillHileman 我正在开发一个混合应用程序,所以基本上,整个应用程序都呈现在 Web 视图上。而且我找不到弹出窗口的元素,所以现在你能解释一下 getContextHandles() 将如何工作而不是 getWindowHandles () ???
  • 我将发布一个我自己的代码示例,该示例将切换到第一个可用的 Web 上下文作为建议的答案。

标签: java selenium appium hybrid-mobile-app appium-android


【解决方案1】:

此错误消息...

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

...暗示 WebDriver 变体无法与所需的 WebElement(s) 交互。

您的主要问题是您使用的二进制文件版本之间的不兼容性,如下所示:

  • 您的 Selenium 客户端 版本是 2018-11-14T08:17:033.141.59,这是最新版本。李>
  • 您的 JDK 版本是 1.8.0_152-release,相当oldancient

所以 Selenium Client v3.141.59 和 JDK v1.8.0_152-release 之间存在明显的不匹配。

解决方案

【讨论】:

  • 可能是因为解释有误。你是如何从Method has not yet been implementedunable to interact with the desired WebElement 的? OP 在getWindowHandles() 上收到错误消息。
  • 感谢@DebanjanB 的友好回复。
  • 我将 JDK 更新到 1.8.0_202,但我仍然面临同样的问题。
  • 2019 年 4 月 10 日下午 12:23:41 org.openqa.selenium.remote.ErrorCodes toStatus INFO:HTTP 状态:“404”->“未知方法”的 JSON 状态映射不正确(预期为 405 ) org.openqa.selenium.UnsupportedCommandException:方法尚未实现构建信息:版本:'3.141.59',修订:'e82be7d358',时间:'2018-11-14T08:17:03' 系统信息:主机: 'VIKSHAH2-M-F1AR', ip: 'fe80:0:0:0:1046:c26d:1be1:cb9e%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.版本:'10.14.3',java.version:'1.8.0_202' 驱动信息:io.appium.java_client.AppiumDriver
【解决方案2】:

您是否启用了setWebContentsDebuggingEnabled 属性?不幸的是,在您的应用程序构建中还需要一个额外的步骤。如 Android 远程调试文档中所述,必须将 android.webkit.WebView 元素上的 setWebContentsDebuggingEnabled 属性设置为 true。

如果尚未启用,请让开发人员在生成构建之前设置为 true。

【讨论】:

  • 感谢您的回复。 @Uday Seshardri,正如我上面提到的,这是非原生的混合应用程序,我发现 setWebContentsDebuggingEnabled 是这样的:developers.google.com/web/tools/chrome-devtools/…
  • 即使它是一个混合应用程序。 Android manifest.xml 文件将出现。
  • 从以下链接中寻找答案
【解决方案3】:

下面是我用来从可用上下文切换到第一个 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;
}

【讨论】:

  • 感谢您的回复,但在我的情况下这对我不起作用。实际上,这是我的主要问题:stackoverflow.com/questions/55708412/… 当我尝试使用 webDriver.getWindowHandles() 获取下拉元素时,会发生此错误。
猜你喜欢
  • 2015-12-20
  • 2017-06-09
  • 2019-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-25
  • 2018-09-15
  • 2017-05-07
相关资源
最近更新 更多