Rayrun
← Back to videos

Playwright - Turn Page Object Model Pages into fixtures

Playwright Tutorial for turning Page Object Model Pages into fixtures. This is the preferred approach when using Playwright test and page object model

In this video tutorial, Jared from Commit to Quality shows us how to extend the Page Object Model in Playwright by creating new fixtures for the classes. This method tidies up tests and makes them more readable.

To start with, Jared creates a new folder called 'fixtures' inside the test folder and inside it, he creates a new file called 'basePage.ts'. Inside the file, he imports the necessary classes and then extends the basic test provided by Playwright to add new fixtures for the page object model classes or pages. Here's a quick rundown of the steps:

  1. Import the necessary classes.
  2. Extend the basic test by providing new fixtures for the page object model classes or pages.
  3. Define the fixtures and their types.
  4. Uncomment the instances of the classes created in the test file.
  5. Import the extended test from the 'fixtures/basePage' file.
  6. Rerun the test to make sure everything is working as expected.

With these simple steps, you can easily convert your page object models into fixtures, making your tests more readable and maintainable. So, go ahead and give it a try, and if you have any questions along the way, don't hesitate to drop a comment on the video tutorial!

Related Videos

#16 - ARIA and how Playwright is making use of it to identify UI controls?
#16 - ARIA and how Playwright is making use of it to identify UI controls?
Create feature, steps & config | Playwright & Cucumber - Typescript | Part 1
Create feature, steps & config | Playwright & Cucumber - Typescript | Part 1
Working with multiple elements in Playwright Test (NodeJS)
Working with multiple elements in Playwright Test (NodeJS)
Playwright Test Runner | Playwright - Part 22
Playwright Test Runner | Playwright - Part 22
TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].