附上代码:

capabilities.setCapability("deviceName", "“iOS device");
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("useNewWDA", false);
capabilities.setCapability("useJSONSource", true);
capabilities.setCapability("realDeviceScreenshotter", "idevicescreenshot");
capabilities.setCapability("autoLaunch", "false");
capabilities.setCapability("usePrebuiltWDA", true);
capabilities.setCapability("noReset", true);
capabilities.setCapability("autoAcceptAlerts", true);
capabilities.setCapability("automationName", "XCUITest");
capabilities.setCapability("newCommandTimeout", 999999);
capabilities.setCapability("udid", udid);
capabilities.setCapability("bundleId", bundleID);
capabilities.setCapability("wdaLocalPort", wdaLocalPort


↙↙↙阅读原文可查看相关链接,并与作者交流