简体   繁体   中英

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:

在此处输入图像描述

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'));
    // ...
  },
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM