selectOnFinder method

Future<void> selectOnFinder(
  1. Finder finder,
  2. String value, {
  3. TestStep? step,
  4. Future<void> onBeforeSelection()?,
})

Implementation

Future<void> selectOnFinder(
  Finder finder,
  String value, {
  TestStep? step,
  Future<void> Function()? onBeforeSelection,
}) async {
  if (value.isEmpty) {
    throw EnsembleTestFailure('select requires "value"');
  }
  await tapFinder(
    finder,
    step: step,
    onBeforeTap: () async {
      if (step != null) await _emitEvidenceBoundary(step);
      await onBeforeSelection?.call();
    },
  );
  final option = find.text(value);
  if (option.evaluate().isEmpty) {
    throw EnsembleTestFailure('select could not find option "$value"');
  }
  await tester.tap(option);
  await runtime.settleAfterAction();
}