Robotium 4.0 – Web Support!

Robotium is a UI test framework for Android applications. With Robotium, test case developers can in easy fashion write function and system tests for Android applications. Robotium has until now only had support for native Android applications. With the newly released Robotium 4.0 that has changed and now Robotium has full support for hybrid applications. Hybrid applications are applications that use WebViews to present the HTML and JavaScript files in full-screen, using the native browser rendering engine.

Web support has been built in. Now the below methods also support web content:

clickOnText(String text)
searchText(String text)
waitForText(String text)
scrollUp/Down()
takeScreenshot()

Besides building in web support, Robotium 4.0 comes with a set of new methods that are directly aimed for interaction with web content:

clickOnWebElement(By by)
waitForWebElement(By by)
getWebElement(By by)
enterTextInWebElement(By by)
typeTextInWebElement(By by)
clearTextInWebElement(By by)

By is a static object that has been introduced to allow test case developers to select web content based on their id, name, tagName, textContent and className. Examples are By.id(String id) and By.className(String className).

Besides the Web support, a new class: RobotiumUtils is available that contains utility methods that can filter, order and sort Views. Examples are: removeInvisibleViews(Iterable viewList), filterViews(Class classToFilterBy, Iterable viewList) and filterViewsToSet(Class classSet[], Iterable viewList).

in Robotium 4.0 the activity handling has been further improved making methods like: finishInactiveActivities() and getAllOpenedActivities() obsolete. Also the new method getCurrentViews(Class classToFilterBy) replaces the old specific getCurrentX methods (e.g. solo.getCurrentViews(ListView.class) replaces solo.getCurrentListViews()).

To download the latest release of Robotium and it’s javadoc please go to the Downloads page.

I hope you will enjoy Robotium 4.0!

This Post Has 8 Comments

  1. Hi,

    I am trying to test a Hybrid app on Android. I wrote some code:

    public void testSample() throws Exception {
    By byKitchensink = By.xpath(“//a[./img[@src=’kitchensink/resources/icons/icon.png’]]”);
    solo.waitForWebElement(byKitchensink, 60000, false);
    solo.clickOnWebElement(byKitchensink, 0, false);
    Log.d(getName(), “Clicked Kitchensink”);
    By byUserInterface = By.xpath(“//div[./span[text()=’User Interface’]]”);
    solo.waitForWebElement(byUserInterface, 60000, false);
    solo.clickOnWebElement(byUserInterface, 0, false);
    }

    But the click action does not work:
    solo.clickOnWebElement(byKitchensink, 0, false);

    I am sure the xpath “By” can be found, because it works, and, if I click the Web Element manually, the downstream steps work well.

    Could you help on this?

    Thank you very much, :)

      1. Oh, yes, thank you, I have logged a bug in the issue tracker.

        Sorry, it is not appropriate that I posted this issue on this page, is it possible to remove it from this page?

  2. Hi,

    Any idea about How to find Xpath for webelements on android browser,

    please help to provide any tools information if it is supported

  3. Hi,

    Any idea about How to find the Xpath on Android browser.

    Regards,
    Lakshman

  4. I have a datepicker created using phonegap (cordova). Not able to get it working with robotium . Any suggestion would be higly appreciated

  5. Bolt Zhang…just verify the click is support on these web elements where u want to click as similar to selenium on some web elements.

  6. What steps will reproduce the problem?
    1. First time test webview elements by solo.typeTextInWebElement(username, “Tom”) and
    solo.typeTextInWebElement(password, “123”) correctly entered these two editText and takes your to next page
    2. But second time test now WebElements are incorrectly entered, i.e Tom123 are entered as username

    What is the expected output?
    username Tom (on first time run)
    password 123

    What do you see instead?
    username Tom123 (on second run)

    So my thinking was that tearDown not was correct?

    @After
    public void tearDown() throws Exception {

    solo.clearTextInWebElement(By.id(“username_or_email”));
    solo.clearTextInWebElement(By.id(“password”));
    solo.finishOpenedActivities();

    What version of the product are you using?
    5.4.1

    On what operating system?
    Android Studio Mac OSX Yosemite

Leave a Reply

Close Menu