diff --git a/lib/src/flutter/configuration/flutter_test_configuration.dart b/lib/src/flutter/configuration/flutter_test_configuration.dart index 77617f4..fbef4ef 100644 --- a/lib/src/flutter/configuration/flutter_test_configuration.dart +++ b/lib/src/flutter/configuration/flutter_test_configuration.dart @@ -29,6 +29,7 @@ class FlutterTestConfiguration extends TestConfiguration { whenPauseStep(), whenFillFieldStep(), thenExpectWidgetToBePresent(), + thenExpectWidgetToBeAbsent(), restartAppStep(), siblingContainsTextStep(), tapTextWithinWidgetStep(), diff --git a/lib/src/flutter/steps/then_expect_widget_to_be_present_step.dart b/lib/src/flutter/steps/then_expect_widget_to_be_present_step.dart index 225bbff..deb6d86 100644 --- a/lib/src/flutter/steps/then_expect_widget_to_be_present_step.dart +++ b/lib/src/flutter/steps/then_expect_widget_to_be_present_step.dart @@ -29,3 +29,22 @@ StepDefinitionGeneric thenExpectWidgetToBePresent() { configuration: StepDefinitionConfiguration()..timeout = const Duration(days: 1), ); } + +StepDefinitionGeneric thenExpectWidgetToBeAbsent() { + return given2( + RegExp(r'I expect the (?:button|element|label|icon|field|text|widget|dialog|popup) {string} to be absent within {int} second(s)$'), + (key, seconds, context) async { + await context.world.appDriver.waitUntil( + () async { + await context.world.appDriver.waitForAppToSettle(); + + return context.world.appDriver.isAbsent( + context.world.appDriver.findBy(key, FindType.key), + ); + }, + timeout: Duration(seconds: seconds), + ); + }, + configuration: StepDefinitionConfiguration()..timeout = const Duration(days: 1), + ); +}