A Page Object Model (POM) puts the selectors and actions of one page in one class, so your tests read like intentions and a UI change is fixed in one place. Here is the smallest version that is still useful, written for Playwright Test with TypeScript. I ran every file below against the public Playwright demo app, TodoMVC , with Playwright 1.65.
Project layout
playwright . config . ts pages / todo - page . ts tests / todo . spec . ts
Enter fullscreen mode
Exit fullscreen mode
The config, and a trap
// playwright.config.ts import { defineConfig } from '@playwright/test' ;
export default defineConfig ( { testDir : './tests' , use : { baseURL : 'https://demo.playwright.dev/todomvc/' } , } ) ;
Enter fullscreen mode
Exit fullscreen mode
Note the trailing slash. Playwright resolves page.goto() paths with the standard URL rules. With baseURL: '.../todomvc' (no slash), goto('/') goes to https://demo.playwright.dev/ , not to the app, and the first fill() times out waiting for an input that is not there.…