0

remotewebdriver を使用してインスタンス化すると、オブジェクトが完全に返されます。

しかし、remotewebdriver の代わりに AndroidDriver を使用すると、以下のエラーが発生します。親切に助けてください。

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 Selenium スタンドアロン バージョン: 3.14.0

4

2 に答える 2