org.openqa.grid.common.exception.GridException:无法从请求中提取功能

时间:2018-09-27 05:13:58

标签: selenium appium appium-android remotewebdriver appium-desktop

当我使用remotewebdriver实例化时,我完美地获得了返回的对象。

但是如果我使用AndroidDriver,则不是remotewebdriver,而是出现以下错误。请帮助。

2018-09-27 12:17:09.712:WARN:osjs.HttpChannel:qtp817406040-14: /wd/hub/session java.io.IOException: org.openqa.grid.common.exception.GridException: Cannot extract a capabilities from the request: {
  "desiredCapabilities": {
    "appPackage": "com.xxxxxxx.ymca",
    "clearSystemFiles": "true",
    "noReset": "true",
    "noSign": true,
    "deviceName": "Altitude",
    "fullReset": "false",
    "version": "",
    "platform": "ANDROID",
    "appWaitDuration": 60,
    "appActivity": "com.ytlcomms.ymca.activities.LoginActivity",
    "newCommandTimeout": 60,
    "automationName": "UiAutomator2",
    "autoGrantPermissions": true,
    "browserName": "android",
    "platformName": "Android"
  },
  "capabilities": {
    "alwaysMatch": {
      "appium:appActivity": "com.ytlcomms.ymca.activities.LoginActivity",
      "appium:appPackage": "com.xxxxxxxx.ymca",
      "appium:appWaitDuration": 60,
      "appium:autoGrantPermissions": true,
      "appium:automationName": "UiAutomator2",
      "browserName": "android",
      "appium:clearSystemFiles": "true",
      "appium:deviceName": "Altitude",
      "appium:fullReset": "false",
      "appium:newCommandTimeout": 60,
      "appium:noReset": "true",
      "appium:noSign": true,
      "platform": "ANDROID",
      "platformName": "android",
      "version": ""
    },
    "firstMatch": [
      {
      }
    ]
  }
}

这是堆栈跟踪显示的内容:

Caused by: java.lang.IllegalArgumentException: Illegal key values seen in w3c capabilities: [platform, version]

我正在使用以下代码实例化。

RemoteWebDriver getDriver(String appName, String appPackage, String appActivity) {
    DesiredCapabilities androidDcap = DesiredCapabilities.android();
    if (appName.equalsIgnoreCase("YMCA"))
        androidDcap.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");
    androidDcap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
    androidDcap.setCapability(MobileCapabilityType.BROWSER_NAME, "");
    androidDcap.setCapability(MobileCapabilityType.DEVICE_NAME, "Altitude");
    androidDcap.setCapability(MobileCapabilityType.CLEAR_SYSTEM_FILES, true);
    androidDcap.setCapability("autoGrantPermissions", "true");
    androidDcap.setCapability(MobileCapabilityType.NO_RESET, true);
    androidDcap.setCapability(MobileCapabilityType.FULL_RESET, false);
    androidDcap.setCapability(AndroidMobileCapabilityType.NO_SIGN, true);
    androidDcap.setCapability(AndroidMobileCapabilityType.AUTO_GRANT_PERMISSIONS, true);
    androidDcap.setCapability(AndroidMobileCapabilityType.APP_WAIT_DURATION, 60);
    androidDcap.setCapability("newCommandTimeout", 60);
    androidDcap.setCapability("appPackage", appPackage);
    androidDcap.setCapability("appActivity", appActivity);
    try {
        if (System.getProperty("location").equalsIgnoreCase("local")) {
            driver = new RemoteWebDriver(new URL("http://127.0.0.1:4651/wd/hub"), androidDcap);
        } else {
            driver = new RemoteWebDriver(new URL(PropertyHelper.getProperties("REMOTE_HUB_URL")), androidDcap);
        }
    } catch (Exception e) {
        logger.error("Driver instantiating failed", e);
    }
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    return driver;
}

Appium Java客户端版本:6.1.0 硒独立版本:3.14.0

1 个答案:

答案 0 :(得分:0)

我有同样的问题。通过降级selenium-standalone-server-3.13.0来解决

这里的问题是您应该使用java-client中提供的selenium-standalone-server版本。就我而言,我正在使用java-client-6.1.0。为此,我们需要使用selenium-standalone-server-3.13.0

Please see here

您可以获取较旧版本的jar文件here