对于Android HttpUnit的/等价的HtmlUnit [英] HttpUnit/HtmlUnit equivalent for android
问题描述
我正在寻找在Android浏览器的模拟磁带库,它处理像
I'm looking for a browser-simulating library on android, which handles things like
- 在加载网页(HTTP / HTTPS)
- 重定向:HTTP(3xx状态codeS),JavaScript中,HMTL标签
- 在填写HTML表单
- 在简单的HTML解析(可能会回落到JSoup那一个)
HttpUnit的或 的HtmlUnit会做只是罚款,但他们两人都痛苦让运行在Android上。
HttpUnit or HtmlUnit would do just fine, but both of them are a pain to get running on android.
是否有任何其他选项比(安卓)的HttpClient(并因此做大量上述的我自己)等?或者,我可以以某种方式得到采用了Android的WebKit /浏览器?
Is there any other option other than (Android)HttpClient (and therefore doing lots of the above on my own)? Or can I somehow get use of the android webkit/browser?
在此先感谢!
推荐答案
我会建议你看一看的 AndroidDriver 硒。这似乎是一个简单的方法来简单的测试web应用的Android测试框架。
I would recommend you to have a look at AndroidDriver for selenium. It seems to be a straightforward approach to easy test WebApplications with the Android Testing Framework.
您必须使用活动,其中包括一个web视图,以便测试HTTP / HTTPS的网站。 该驱动程序实例化这个活动:
You must use an Activity that includes a WebView in order to test HTTP/HTTPs websites. The Driver is instanciated with this Activity:
WebDriver driver = new AndroidWebDriver(getActivity());
下面是一个简单的测试,从上面的链接引用:
Here is a sample test, quoted from the link above:
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);
}
这篇关于对于Android HttpUnit的/等价的HtmlUnit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!