Waiting for unknown interaction result can be easily satisfied by Retrievers and their ability to wait for change of the conditions and also return the current value.
We can modify the application introduced in the previous example - we do not have application generating sequence of numbers, it generates the random numbers greater than previous one. For this purpose we have one button, and one input box:
In this example, the retrieveText is the Retriever (with type TextRetriever) and waitForChange is a method which waits for change of the first argument's value to value obtained by retriever specified as second argument.
We can also tune this sample in several ways:
1) use the second version of waitForChange, called waitForChangeAndReturn, which additionally returns the new value:
2) We can introduce the retriever e.g. on class properties level, and then we can call it in the test on every place we need the value.
3) we can create own Retriever, which will not return the String, but Long instead (such retriever is not currently implemented in Library). It will little simplify our tests.