使用Appium,如何在模拟器中运行Chrome浏览器?

时间:2018-02-06 12:34:11

标签: android-emulator appium

Appium版本:1.0.0

DesiredCapabilities cap=new DesiredCapabilities();

cap.setCapability(CapabilityType.PLATFORM, MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME,"emulator-5554");
cap.setCapability(MobileCapabilityType.BROWSER_NAME,"Chrome");
cap.setCapability("apppackage","com.anroid.chrome");
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT,"100");

AndroidDriver<AndroidElement> driver=new AndroidDriver<AndroidElement>(new URL("http://0.0.0.0:4723/wd/hub"),cap);
driver.get("https://www.google.co.in");

1 个答案:

答案 0 :(得分:0)

此配置适用于我: Appium服务器1.7.1 java-client 5.0.4

DesiredCapabilities cap=new DesiredCapabilities();

cap.setCapability(CapabilityType.PLATFORM, MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME,"emulator-5554");
cap.setCapability(MobileCapabilityType.BROWSER_NAME, MobileBrowserType.BROWSER);

AndroidDriver<MobileElement> driver = new AndroidDriver<>(
            new URL("http://127.0.0.1:4723/wd/hub"), caps);
driver.get("https://www.google.co.in");

在这种情况下,将使用默认浏览器。如果您想要Chrome,请确保预装在模拟器上 如果是,您可以使用MobileBrowserType.CHROME