Skip to content

Conversation

@CrazyPug
Copy link
Owner

@CrazyPug CrazyPug commented Jan 19, 2025

Instead of repeating the same Playwright calls to fetch the locators we use the Page Object pattern for all currently used pages.

I experimented with two approaches. The first approach was to reflect all possible actions with dedicated functions in page object. This ended up being a lot of boilerplate code. The second approach was to create the most popular selectors and save them as page object fields. Those locators that are used only one time, usually specific to the given test, are not included in the page object but created manually. This approach feels to be better for the current state of the project as it allows to avoid re-creating the same locators over and over again and at the same time we are not introducing too much boilerplate code.

LoginPage is a class representing Page Object Model
for the login page. As of now, it contains one
method allowing to perform successful authentication.
Instead of repeating the same playwright calls to
fetch the locators we use the Page Object Model
pattern for the login page.

I am still not sure if this is the correct approach.
LoginPage class nicely encapsulates all playwright
calls but there is quite a lot of boilerplate code.
Instead of repeating the same Playwright calls to fetch the locators we
use the Page Object Model pattern for all currently used pages.

I experimented with two approaches. The first approach was to reflect
all possible actions with dedicated functions in page object. This ended
up being a lot of boilerplate code. The second approach was to create
the most popular selectors and save them as page object fields. Those
locators that are used only one time, usually specific to the given
test, are not included in the page object but created manually. This
approach feels to be better for the current state of the project as it
allows to avoid re-creating the same locators over and over again and at
the same time we are not introducing too much boilerplate code.
@CrazyPug CrazyPug changed the title Page Object Model pattern - Login page Refactored tests to follow page object pattern Feb 8, 2025
@CrazyPug CrazyPug marked this pull request as ready for review February 8, 2025 22:37
@CrazyPug CrazyPug merged commit 59e964c into main Feb 8, 2025
1 check passed
@CrazyPug CrazyPug deleted the login-page branch February 8, 2025 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant