如何用appium在android中进行web测试

时间:2013-11-12 09:54:42

标签: android web-testing appium

我点击了appium.exe用户界面中的启动按钮,没有配置它。当我运行以下代码时,我的android模拟器中没有首选项。如何在Android模拟器中用appium启动chrome浏览器。

//setup the web driver and launch the webview app.
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("app", "chrome");
desiredCapabilities.setCapability("device", "Android");
URL url = null;
try {
url = new URL("http://localhost:4723/wd/hub");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(url, desiredCapabilities);

// Navigate to the page and interact with the elements on the guinea-pig page using id.
remoteWebDriver.get("http://saucelabs.com/test/guinea-pig");
WebElement div = remoteWebDriver.findElement(By.id("i_am_an_id"));
Assert.assertEquals("I am a div", div.getText()); 
//check the text retrieved matches expected value
remoteWebDriver.findElement(By.id("comments")).sendKeys("My comment"); 
//populate the comments field by id.

//close the app.
remoteWebDriver.quit();

1 个答案:

答案 0 :(得分:1)

Chrome没有安装在SauceLab的Android仿真器上,因此您将无法启动Chrome。最重要的是,Appium通过saucelabs不支持Web测试。