flutter_page_object 0.0.2 copy "flutter_page_object: ^0.0.2" to clipboard
flutter_page_object: ^0.0.2 copied to clipboard

Helps to implement the Page Object pattern in a Flutter app.

flutter_page_object codecov #

flutter_page_object is a Flutter library allowing to write page objects for your application using the PageObject pattern. Using it make your tests easier to write, read and maintain.

Usage #

See example for a complete example.

Your tests will look like this:

testWidgets('tap login button and form completed --> logins', (t) async {
  await t.pumpWidget(const MaterialApp(home: LoginPage()));
  final loginPage = LoginPageObject(t);

  await loginPage.completeForm();
  final homePage = await loginPage.loginButton.tapNavAndSettle();

  expect(homePage, findsOne);
  expect(homePage.greetingText, findsOne);
});

While the page object will look like this:

class LoginPageObject extends PageObject {
  late final username = d.byKey.stringTextFormField(const Key('username'));
  late final password = d.byKey.stringTextFormField(const Key('password'));
  late final loginButton =
      d.byKey.navButton(const Key('login_button'), HomePageObject(t));

  LoginPageObject(WidgetTester t) : super(t, _finder);

  Future<void> completeForm(
      {String username = 'username', String password = 'password'}) async {
    await this.username.setText(username);
    await this.password.setText(password);
    await t.pump();
  }
}

Creating your own page object #

You can create your own page object by simply extending the PageObject base class.

1
likes
0
points
645
downloads

Publisher

unverified uploader

Weekly Downloads

Helps to implement the Page Object pattern in a Flutter app.

Homepage
Repository (GitHub)
View/report issues

Topics

#page-object #testing #test-automation

License

unknown (license)

Dependencies

flutter, flutter_test

More

Packages that depend on flutter_page_object