I want to assert if a string exists using Espresso.
The String Contains a Fixed part and a random number eg: FR#133, were the 133 is a random number. How can I assert it?
- It can be any digit number
- If number is not present the test should fail
I tried the below code that performs a fixed string FR#133 check.
ViewInteraction textView = onView(
allOf(withText("FR#133"),
childAtPosition(
allOf(withId(R.id.toolbar_farmdetail),
childAtPosition(
IsInstanceOf.<View>instanceOf(android.widget.LinearLayout.class),
0)),
1),
isDisplayed()));
textView.check(matches(withText("FR#133")));