我正在尝试在 Sauce Labs 中设置我的第一个 Appium 测试(不是本机或混合应用程序),并且在尝试设置我的功能时遇到 WebDriverException:
org.openqa.selenium.WebDriverException: Unable to parse remote response: Misconfigured -- Unsupported OS/browser/version/device combo: OS: 'unspecified', Browser: 'iphone', Version: '11.2.2.', Device: 'iPhone Simulator'`
这是我设置上限的方法:
public static DesiredCapabilities CreateAppiumCapabilities(String browser, String version, String platform,String device, String methodName) {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, platform);
caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, version);
caps.setCapability(MobileCapabilityType.DEVICE_NAME, device);
caps.setCapability(MobileCapabilityType.AUTOMATION_NAME,"XCUITest");
caps.setCapability(MobileCapabilityType.BROWSER_NAME, browser);
caps.setCapability("appiumVersoin", "1.7.2");
caps.setCapability("name", methodName);
System.out.println(caps);
return caps;
然后,在我的 testBase.java 文件中运行:
private ThreadLocal<IOSDriver> iosDriver = new ThreadLocal<IOSDriver>();
...
...
...
DesiredCapabilities capabilities = SauceUtils.CreateAppiumCapabilities(browser, version, platform, device, methodName);
String url = SauceUtils.getURL();
iosDriver.set(new IOSDriver(new URL(url), capabilities));
sessionId.set(((IOSDriver) getIosDriver()).getSessionId().toString());
System.out.println(caps) 正确显示所有内容:
Capabilities {appiumVersoin: 1.7.2, automationName: XCUITest, browserName: Safari, deviceName: iPhone Simulator, name: appiumTest, platformName: iOS, platformVersion: 11.2.2}
下面是实际测试:
public class AppiumTest extends TestBase {
@Test(dataProvider = "appium", groups = "Appium", description = "simple appium test")
public void appiumTest(String browser, String version, String platform, String device, Method method) throws Exception {
this.createDriver(browser, version, null, method.getName(), device, platform);
IOSDriver<WebElement> mobiledriver = getIosDriver();
mobiledriver.get("http://appium.io/");
Assert.assertEquals(mobiledriver.getCurrentUrl(), "http://appium.io/", "URL Mismatch");
Assert.assertEquals(mobiledriver.getTitle(), "Appium: Mobile App Automation Made Awesome.", "Title Mismatch");
}
}
和getIosDriver()
功能:
public IOSDriver<WebElement> getIosDriver() {
return iosDriver.get();
}
不知道我在这里做错了什么,任何和所有的帮助将不胜感激!:)