arrow-left Back to topicQuizPage object modelsCheck yourself1.Should a page object method contain an expect() assertion?Yes — it's cleaner to assert in the page object so tests are shorterNo — assertions belong in the test. Page objects handle locators and actions onlyOnly for assertions that are needed to make the action safe2.What is the Page Object Model (POM) pattern primarily used for in Playwright tests?To speed up test execution by caching page loadsTo centralise locators and interactions for a UI so changes need to be fixed in only one placeTo generate test data automatically from the page structureTo replace fixtures entirely with class-based setup3.In a Page Object class, what argument does the constructor always receive?A browser instanceA Playwright config objectA Page instanceA BrowserContext instance4.Where should locators be defined in a Page Object class?As local variables inside each method that needs themAs readonly class properties, assigned once in the constructorIn a separate constants file imported by the page objectAs static class properties shared across all instances5.What is the main maintenance advantage of Page Object Model when a UI selector changes?Playwright automatically detects the new selector and updates the page objectYou only need to update the selector in the page object class — all tests using that class are fixed automaticallyThe page object regenerates selectors from the page at runtime so no code change is neededTest failures point directly to the selector in the page object so you know which file to open6.How do Playwright fixtures complement Page Object Model in a test suite?Fixtures replace page objects entirely — you don't need bothFixtures handle setup/teardown (navigate, seed data) and deliver a ready-to-use page object to the testFixtures store the locator strings that page objects then importFixtures automatically generate page objects from the page HTML structure7.A page object method createOrder performs several actions. Should it return this to allow chaining?Yes — returning this from every method is required by Playwright's page object APIYes — returning this from action methods allows test code like orders.goto().createOrder('Laptop', 2).filterByStatus('pending')No — async methods cannot return this in TypeScriptNo — page object methods must always return void8.When does it make sense to extract a Page Object class rather than use inline locators directly in the test?For every test file, even if only one test accesses that pageOnly when the page has more than 20 elementsWhen the same UI is accessed by multiple test files and the duplication becomes a maintenance burdenOnly when the project uses TypeScript, not JavaScriptSubmit answersarrow-left PreviousWeb serverParameterize testsNext arrow-right