select method

Future<void> select(
  1. String id,
  2. String? value, {
  3. TestStep? step,
  4. int? timeoutMs,
  5. Future<void> onBeforeSelection()?,
})

Implementation

Future<void> select(
  String id,
  String? value, {
  TestStep? step,
  int? timeoutMs,
  Future<void> Function()? onBeforeSelection,
}) async {
  if (value == null || value.isEmpty) {
    throw EnsembleTestFailure('select requires "value"');
  }
  try {
    await tap(
      id,
      timeoutMs: timeoutMs,
      onBeforeTap: () async {
        if (step != null) await _emitEvidenceBoundary(step);
        await onBeforeSelection?.call();
      },
    );
  } on TestExecutionError catch (error) {
    throw EnsembleTestFailure(error.message);
  }
  final option = find.text(value);
  if (option.evaluate().isEmpty) {
    throw EnsembleTestFailure('select could not find option "$value"');
  }
  await tester.tap(option);
  await runtime.settleAfterAction();
}