Skip to content

Instantly share code, notes, and snippets.

@PROGrand
Created September 21, 2021 00:35
Show Gist options
  • Save PROGrand/03b7fa0b49642e691148dc010816cc83 to your computer and use it in GitHub Desktop.
Save PROGrand/03b7fa0b49642e691148dc010816cc83 to your computer and use it in GitHub Desktop.
Gherkin step definition for dropdown control
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