I am currently doing some cross-app functional UI testing.
There is a TextView that exists and that I must test for its text value. I must thus find a way to wait for the TextView's text value to change.
Here is my usecase :
final UiSelector contextualInformation = new UiSelector().resourceId(resourceId);
final UiObject contextualInformationUiObject = mDevice.findObject(contextualInformation);
// I would like to find something to fulfill this statement
Boolean conditionWasMet = contextualInformationUiObject.wait(Until./*a search condition for text to contain given substring*/, timeout);
assertThat(conditionWasMet, is(notNullValue()));
assertThat(conditionWasMet, is(true));
assertThat(contextualInformationUiObject.exists(), is(true));
assertThat(contextualInformationUiObject.getText(), containsString(/*given substring*/));
I am well aware of the existence of Until.textContains(/*substring*/)
but I do not know how to apply it to/with contextualInformation
or contextualInformationUiObject
here.
As far as I know, if your process doesn't possess any onFinished
callback, there is no way but to use Thread.sleep()
. This is what I did on my latest project:
final long waitingTime = 5000L;
Thread.sleep(averageWaitingTime);
You can just adjust the waitingTime
. The idea is to buy enough time for your process to finish.