我建议你看看AndroidDriver for selenium。这似乎是一种使用 Android 测试框架轻松测试 Web 应用程序的简单方法。
您必须使用包含 WebView 的 Activity 才能测试 HTTP/HTTPS 网站。驱动程序使用此 Activity 实例化:
WebDriver driver = new AndroidWebDriver(getActivity());
这是一个示例测试,引用自上面的链接:
public void testGoogleWorks()
// Loads www.google.com
driver.get("http://www.google.com");
// Lookup the search box on the page by it's HTML name property
WebElement searchBox = driver.findElement(By.name("q"));
// Enter keys in the search box
searchBox.sendKeys("Android Rocks!");
// Hit enter
searchBox.submit();
// Ensure the title contains "Google"
assertTrue(driver.getTitle().contains("Google"));
// Ensure that there is at least one link with the keyword "Android"
assertTrue(driver.findElements(By.partialLinkText("Android")).size() > 1);
}