I have to get a EditText
object which is nothing but a search bar in app with text visible as Current Location
, however if I've already made a search query with myText
, there is no Current Location
text visible and search bar shows myText
.
I am writing the test cases using Robotium solo object.
How can i write a conditional statement to get the EditText
despite of what text it shows. Something like
if !found solo.getText("Current Location")
search solo.getText("myText");
This is what I am doing currently
EditText text = (EditText) solo.getText("Current Location");
if(text == null){
text = (EditText) solo.getText("myText");
//my rest of the code goes here....
But this throws exception if Current Location
is not present in the search bar.
junit.framework.AssertionFailedError: TextView with text: 'Current Location' is not found!
Please suggest the correct way.