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

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

flutter_page_object codecov #

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.

Let's take a look on an example of a login page in your app.

You can create a LoginPageObject which will look like this:

class LoginPageObject extends PageObject {
  late final username = d.textFormField(_usernameFinder);
  late final password = d.textFormField(_passwordFinder);
  late final loginButton = d.navButton(_loginButtonFinder, HomePageObject.new);

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

While your tests will look like this:

testWidgets('form completed and tap login button --> navigates to home page', (t) async {
  await t.pumpWidget(const App());
  final loginPage = LoginPageObject(t);

  await loginPage.username.enterText('username');
  await loginPage.password.enterText('password');
  await t.pump();
  final homePage = await loginPage.loginButton.tapNavAndSettle();

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

Creating your own page object #

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

Supported page objects #

Contribution #

Your contribution is more than welcome, feel free to contact me on any matter.

1
likes
160
points
645
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)
View/report issues

Topics

#page-object #testing #test-automation

License

MIT (license)

Dependencies

flutter, flutter_test

More

Packages that depend on flutter_page_object