HttpUnit / HtmlUnit equivalent for Android

I am looking for a library to simulate a browser on android that handles things like

  • website loading (http / https)
  • Redirects: HTTP (status codes 3xx), JavaScript, HMTL tags
  • filling out html forms
  • simple html parsing (can go back to JSoup for this)

HttpUnit or HtmlUnit will do just fine, but both of them are a pain to run on android.

Is there any other option besides (Android) HttpClient (and therefore do a lot of the above)? Or can I somehow use the android website for the android browser?

Thanks in advance!

+8
android htmlunit
source share
1 answer

I would recommend you take a look at AndroidDriver for selenium. This is apparently a simple approach to easily testing WebApplications using the Android testing platform.

To check HTTP / HTTP sites, you should use Activity, which includes WebView. The driver was associated with this activity:

WebDriver driver = new AndroidWebDriver(getActivity()); 

Here is a test example 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 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); } 
+3
source

All Articles