1

Matcher应该使用什么? 似乎不再可用,不幸的是我在图书馆visible()找不到替代品。org.hamcrest

提前致谢!

4

1 回答 1

1

You may use Awaitility utility.

This is an example of a utility method where it waits by default up to 10 seconds starting after 10 milliseconds:

public <T extends Node> T lookupById(final String controlId) {
    Awaitility
            .await()
            .pollDelay(10, TimeUnit.MILLISECONDS)
            .until(() -> robot.lookup(controlId).query() != null);

    return robot.lookup(controlId).query();
}

You may implement any condition of waiting, for example, checking of additional visibility property, etc.

The result of negative scenario:

org.awaitility.core.ConditionTimeoutException: Condition with lambda expression in com.MyClass was not fulfilled within 10 seconds.
于 2017-08-11T17:09:32.977 回答