dontSee method

Future<void> dontSee(
  1. Object target, {
  2. Duration? timeout,
})

Waits for target to be off the screen.

Implementation

Future<void> dontSee(Object target, {Duration? timeout}) async {
  final PlaybookFinder finder = Find.target(target);
  final Duration limit = timeout ?? this.timeout;
  final Duration start = _clock.elapsed;
  while (true) {
    _checkStopped();
    final PlaybookTree tree = _tree();
    if (!_anyVisible(finder.find(tree))) return;
    if (_clock.elapsed - start >= limit) {
      throw PlaybookFailure(
        'Still see ${finder.description} after ${_seconds(limit)}.',
        visibleText: tree.visibleText(),
      );
    }
    await _sleep(_poll);
  }
}