Testing / Playwright Interview questions
What are Playwright's API testing capabilities?
Beyond browser automation, Playwright includes an APIRequestContext for making direct HTTP requests, without launching a browser at all.
const response = await request.post('/api/login', { data: { email: 'a@b.com', password: 'secret' }, }); expect(response.status()).toBe(200); const body = await response.json();
This context shares the same cookie jar as a browser context when created from one, which makes it possible to set up application state via fast API calls (like creating a test user) before switching to UI actions for the part actually under test - avoiding slow UI-driven setup for every test. It also supports the same request/response inspection used for network mocking, making it useful for pure backend contract testing independent of any UI.
More Related questions...