Three questions from the bank, with answers. The practice test draws different ones each time.
Question 1 · Playwright Network Handling · senior
In Playwright, what is the most reliable approach for a senior test automation engineer to wait for a specific asynchronous API response after a user action?
await page.click('#submit');
// How to ensure the network request triggered by this click finishes?
D. await page.waitForResponse(response => response.url().includes('/api/submit') && response.status() === 200);
waitForResponse ensures that the specific network call triggered by the action has completed and returned its status, preventing race conditions. Relying solely on networkidle can be flaky if polling or analytics requests keep the connection active.
Question 2 · Playwright Actionability · senior
In Playwright, what happens under the hood when you call an action method like page.click() or element.hover()?
const element = await page.locator('.item');
await element.hover();
await page.locator('.tooltip').click();
A.The hover action will pass, but click will fail due to missing explicit await page.waitForSelector
B.Playwright automatically waits for the element to be visible, stable, and enabled before interacting
C.Playwright will wait for the network to be idle before hovering
D.The test will immediately throw a TimeoutError because hover does not auto-wait
Show answer
B. Playwright automatically waits for the element to be visible, stable, and enabled before interacting
Playwright automatically performs actionability checks (visible, enabled, stable) before executing actions like hover or click, making explicit waits for visibility unnecessary in most cases.
Question 3 · Page Object Model Anti-patterns · senior
When scaling a test automation framework using the Page Object Model (POM), which anti-pattern should senior engineers strictly avoid?
// Page Object Model (POM) base class
class BasePage {
constructor(page) {
this.page = page;
}
}
A.Placing test assertions (e.g., expect(el).toHaveText()) directly inside the Page Object methods
B.Storing locators as private properties
C.Extending a common BasePage class
D.Using async methods for navigation
Show answer
A. Placing test assertions (e.g., expect(el).toHaveText()) directly inside the Page Object methods
Embedding assertions inside Page Objects violates the Single Responsibility Principle and couples the page structure with test assertions, making maintenance harder when assertions change across different test scenarios.