IOSDriver无法解析构造函数,想要将DesiredCapabilities转换为Capabilities

时间:2018-07-17 18:51:45

标签: java selenium-webdriver appium-ios

package AppiumTest;

import java.net.URL;
import java.net.MalformedURLException;

import org.testng.annotations.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.CapabilityType;
import io.appium.java_client.ios.IOSDriver;

public class TestIOSSafariBrowser{
    @Test
    public void startBrowser() throws MalformedURLException {
        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability("deviceName","iPhone 8");
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("platformVersion", "11.4.1");
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "safari");

        IOSDriver driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

        driver.get("http://www.google.com");

        System.out.println("Page title is " + driver.getTitle());
    }
}

我对使用Selenium和Appium比较陌生。

我正在尝试打开Safari通过Xcode和Appium访问Google。当我在下面将IOSDriver实例化为驱动程序时,IOSDriver不允许我传递DesiredCapabilities对象(功能),而是希望我传递Capabilities对象。如果我使用Capabilities对象而不是DesiredCapabilities,我将如何尝试打开Safari并访问Google主页?

0 个答案:

没有答案