20. Actionability Checks & Network Synchronization

Playwright's 5 Actionability Checks

Before performing an action like click(), Playwright verifies: 1. Attached: Present in the DOM. 2. Visible: Has non-empty bounding box, not hidden. 3. Stable: CSS animations and transitions have finished. 4. Receives Events: Not obscured by modal overlays or spinners. 5. Enabled: disabled attribute is false.
// ✅ Best Practice: Wait for the exact network response
const responsePromise = page.waitForResponse("**/api/checkout");
await page.getByRole("button", { name: "Place Order" }).click();
const response = await responsePromise;
expect(response.status()).toBe(200);

Task

  • Implement isActionable:
  • 1. Accept status object with attached, visible, stable, enabled booleans.
  • 2. Return true only if all 4 are true.
💡Common doubts
Did you like the problem?
Lesson 20 of 35
JavaScript
Loading code editor…
Next