无法启动Andrioddriver

时间:2018-06-27 11:34:25

标签: appium appium-android

由于我在编写简单的测试脚本时不熟悉Appium,因此无法启动Android驱动程序并收到以下错误消息:

  

“构造函数AndroidDriver(DocFlavor.URL,DesiredCapabilities)是   未定义”

请对此提供帮助。

public class test {

    @Test
    public void test1()
    {
        DesiredCapabilities capabilities = DesiredCapabilities.android();

        capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, BrowserType.CHROME);

        //capabilities.setCapability(MobileCapabilityType.PLATFORM, Platform.ANDROID);

        //capabilities.setCapability(MobileCapabilityType.PLATFORM, Platform.ANDROID);

        capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "ANDROID");

        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "3618ca1");    

        capabilities.setCapability(MobileCapabilityType.VERSION, "8.0.0");

        URL url = new URL("http://0.0.0.0:4723/wd/hub");

        RemoteWebDriver driver =new AndroidDriver(url, capabilities);
    }
}  

1 个答案:

答案 0 :(得分:1)

您可以在@Before而不是@Test下尝试上述代码,因为@Before中的代码将在执行测试之前运行,以便初始化Android驱动程序。