Robotium for Android - solo.searchText () not working


I’m having a problem with searchText() function used with Robotium.

I’m searching for this string:

<string name="provisioning_wizard_title_2">Service Activation Wizard (Step 2)</string>

I defined it in string xml, and I’m searching it this way:

Activity act=solo.getCurrentActivity(); 
String string = solo.getString(act.getResources().getIdentifier("provisioning_wizard_title_2", "string", act.getPackageName()));

It fails when I call


and it fails also if i call:

assertTrue(solo.searchText("Service Activation Wizard (Step 2)"));

even if that is the string I’m seeing in the focused screen activity.

The strange thing is that it works if I use the same string without last character:

assertTrue(solo.searchText("Service Activation Wizard (Step 2"));

and it works if I use

assertTrue(solo.searchText(string.substring(0, string.length()-1)));

I hope someone could help me.

Sorry for my english!

Thank you.

I solved problem thanks to Renas Reda (Founder and maintainer of Robotium).
The problem is due to regex support in searchText(); some characters will trigger it.
Use Pattern.quote(string)
Example: Pattern.qoute(“provisioning_wizard_title_2”) and eveything works good!

  • You must to post comments

I usually use Solo#waitForText(...) so I make sure I’m not losing some race condition.

Try this:

assertTrue(solo.waitForText( solo.getString(R.string. provisioning_wizard_title_2) );

Make sure you are importing the correct file from your production project (not the test project).

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.