enterTextByIndex method

Future<void> enterTextByIndex(
  1. String text, {
  2. required int index,
  3. String? appId,
  4. KeyboardBehavior? keyboardBehavior,
  5. Duration? timeout,
})

Enters text to the index-th visible text field.

If the text field at index isn't visible immediately, this method waits for the view to become visible. It prioritizes the timeout duration provided in the method call. If timeout is not specified, it utilizes the NativeAutomatorConfig.findTimeout duration from the configuration.

Native views considered to be texts fields are:

  • EditText on Android
  • TextField or SecureTextField on iOS

See also:

  • enterText, which allows for more precise specification of the text field to enter text into

Implementation

Future<void> enterTextByIndex(
  String text, {
  required int index,
  String? appId,
  KeyboardBehavior? keyboardBehavior,
  Duration? timeout,
}) async {
  await _wrapRequest(
    'enterTextByIndex',
    () => _client.enterText(
      EnterTextRequest(
        data: text,
        appId: appId ?? resolvedAppId,
        index: index,
        keyboardBehavior:
            (keyboardBehavior ?? _config.keyboardBehavior).toContractsEnum,
        timeoutMillis: timeout?.inMilliseconds,
      ),
    ),
  );
}