Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can integration_test package interact with webview?

I use integration_test package to write UI tests on Dart for iOS and Android platforms. I also have a webview in my app showing login page with text fields. I use webview_flutter for it.

Does anybody know if tester can interact with my webview within integration test? Can I find a textfield on the webpage and enter text into it?

I want to write test code like this, but for the webview:

testWidgets('Authorization test', (tester) async {
  ...
  await tester.enterText(find.byKey(Key('login_text_field')), 'login');
  await tester.enterText(find.byKey(Key('password_text_field')), 'password');
  await tester.tap(find.byKey(Key('sign_in_button')));
  await tester.pumpAndSettle();
}

Here is content of the web page:

enter image description here

like image 238
Mol0ko Avatar asked Apr 11 '26 07:04

Mol0ko


1 Answers

This is now possible with Patrol!

You could write your test like this:

patrolTest(
  'Authorization test',
  nativeAutomation: true,
  ($) async {
    // ...
    await $.native.enterTextByIndex('login', index: 0);
    await $.native.enterTextByIndex('password', index: 1);
    await $.native.tap(Selector(text: 'Sign in'));
    // ...
  },
);
like image 177
Bartek Pacia Avatar answered Apr 13 '26 00:04

Bartek Pacia