Back to All Questions
Question 82 of 100
Debugging
Beginner
What is the use of page.pause()?
The Answer
`page.pause()` stops test execution at that point and opens the Playwright Inspector, letting you inspect the page, run Playwright commands interactively, and continue execution manually.
Deep Dive Explanation
`page.pause()` only works in headed mode (not in CI). It's the equivalent of a browser breakpoint for Playwright tests. Use it temporarily during development, then remove it before committing. The Inspector also lets you hover over elements to see their resolved locators.
example.spec.ts
test('debug with pause', async ({ page }) => {
await page.goto('/checkout');
await page.getByLabel('Card Number').fill('4111111111111111');
await page.pause(); // βΈοΈ Test stops here, Inspector opens
// After you click 'Resume' in Inspector, execution continues
await page.getByRole('button', { name: 'Pay Now' }).click();
});
// Run in headed mode for pause to work
// npx playwright test --headed
// Or use PWDEBUG env var for full debug mode
// PWDEBUG=1 npx playwright test