In this article we are going to see how to search a Button or a text at an Android device while performing Unit Testing using robotium framework.

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

For Buttons : 
-To search a button with a specific text. It will scroll automatically.
solo.searchButton("ButtonToSearch");

-To search a button with a specific text and only if it is visible on the screen(true for visible).  It will scroll automatically if needed.
solo.searchButton("ButtonToSearch", true);

-To search a button with a specific text and minimum number matching (integer). It will scroll automatically if needed.
solo.searchButton("ButtonToSearch", 2);

-To search a button with a specific text ,minimum number matching (integer) and Visibility(true if it is visible on the scvreen). It will scroll automatically if needed. 
solo.searchButton("ButtonToSearch", 2, true );


-To search a Toggle button with a specific text. It will scroll automatically.
solo.searchToggleButton("ButtonToSearch");


-To search a Toggle button with a specific text and minimum number matching (integer). It will scroll automatically if needed.
solo.searchToggleButton("ButtonToSearch", 2);   

For Text : 
-To search a specific text in a text area(Edit text object). It will scroll automatically if needed. 
solo.searchEditText("SearchText");

-To search a specific text in full display. It will scroll automatically if needed.
solo.searchText("SearchText");

-To search a specific text in full display with Visibility(true to search in visible area on screen). It will scroll automatically if needed.
solo.searchText("SearchText", true);

-To search a specific text in full display with minimum number matching (integer) . It will scroll automatically if needed.
solo.searchText("SearchText", 2);

-To search a specific text in full display with minimum number matching (integer) and Scrolling option(true to enable scroll).
solo.searchText("SearchText", 2,true);


-To search a specific text in full display with minimum number matching (integer) ,Scrolling option(true to enable scroll). solo.searchText("SearchText", 2, true, true);

Note :
-All of these functions returns true if the search item is found, false on not found. So, it is useful for validating items on the screen.
-All text that are used as parameter, will be handled as Regular Expression searching.
-In all Match number,  0 means one or more expected matching

Thanks...:)