Created
September 21, 2021 00:35
-
-
Save PROGrand/03b7fa0b49642e691148dc010816cc83 to your computer and use it in GitHub Desktop.
Gherkin step definition for dropdown control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter_gherkin/flutter_gherkin.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:gherkin/gherkin.dart'; | |
final givenITapDropdownItem = given2<String, String, FlutterWorld>(RegExp(r'I tap (?:a|an|the) {string} within (?:a|an|the) {string} dropdown'), (menuItemKey, dropdownKey, context) async { | |
await context.world.appDriver.waitForAppToSettle(); | |
final finder = context.world.appDriver.findBy(dropdownKey, FindType.key); | |
await context.world.appDriver.scrollIntoView( | |
finder, | |
); | |
await context.world.appDriver.waitForAppToSettle(); | |
await context.world.appDriver.tap( | |
finder, | |
timeout: context.configuration.timeout, | |
); | |
await context.world.appDriver.waitForAppToSettle(); | |
{ | |
final timeout = | |
context.configuration.timeout ?? const Duration(seconds: 20); | |
final finder = (context.world.appDriver.findBy(menuItemKey, FindType.key) as Finder).last; | |
final isPresent = await context.world.appDriver.isPresent( | |
finder, | |
timeout: timeout * .2, | |
); | |
if (!isPresent) { | |
await context.world.appDriver.scrollUntilVisible( | |
(context.world.appDriver.findBy(menuItemKey, FindType.key) as Finder).last, | |
dy: -100.0, | |
timeout: timeout * .9, | |
); | |
} | |
await context.world.appDriver.tap( | |
finder, | |
timeout: timeout, | |
); | |
await context.world.appDriver.waitForAppToSettle(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment