2013-05-29

How to insert text / type in Robotium?

In this article we are going to see how to insert a text or data using at an Android device while performing Unit Testing using robotium framework. Android handles those keys like as soft key board.

We need to initiate the Solo object. After initiation, we will uses solo to get those.

-To enter a text to a specific editable text area (EditText object) . In here myEditText is the EditText item
solo.enterText(myEditText, "InputString");

-To enter a text to a index(0 based) of a editable text area 
solo.enterText(1,"MyString");

-To enter a text in a specific web element . Use any one By method to get web element.
solo.enterTextInWebElement(By.id("uid"), "shantonu");

Like as Entering Text,, we can type the text also. The basic difference, it will keep a delay as well as use different event in android.

-To type a text in a specific editable text area (EditText object)
 solo.typeText(myEditText, "StringToType");

-To type a text to a index(0 based) of a editable text area
solo.typeText(0, "StringToType");

-To enter a text in a specific web element . Use any one By method to get web element.
solo.typeTextInWebElement(By.id("uid"), "StringToType");


-To enter a text in a specific web element object. myWebElement is a web element object.
solo.typeTextInWebElement(myWebElement, "StringToType");


-To enter a text in a specific web element and index(0 based) of matches. Use any one By method to get web element.
solo.typeTextInWebElement(By.id("uid"), "StringToType", 0);

Thanks..:) 

1 comment:

  1. I'mgone to inform my little brother, that he should also pay a visit this
    web site on regular basis to obtain updated from latest news update.


    My site: scrum Mobile development

    ReplyDelete