arrow-left Back to topicQuizNetworkCheck yourself1.You want to test how your app handles a 500 error from /api/orders. What do you use?page.on('response', ...) to listen for the errorpage.route('**/api/orders', route => route.fulfill({ status: 500 }))page.waitForResponse('/api/orders')2.Why should you set up page.waitForResponse() BEFORE the click that triggers the request?It doesn't matter — Playwright queues all responsesThe response might arrive before waitForResponse() is called, causing a racepage.waitForResponse() requires the request URL to be registered first3.Which method do you call inside a route handler to prevent a request from ever reaching the server?route.continue()route.fulfill({ status: 0 })route.abort()route.stop()4.You want to intercept /api/orders, get the real server response, add a field to the first item, and return the modified data to the page. Which combination achieves this?route.continue() with modified headers onlyroute.fetch() to get the real response, then route.fulfill({ response, json: modified }) to send the patched versionpage.waitForResponse() then mutate the response object in placeroute.fulfill({ json: {} }) to replace everything with empty data5.You want to add an Authorization header to every request that goes to /api/**. Which approach is correct?page.on('request', req => req.headers()['Authorization'] = 'token')page.route('/api/', async route => route.continue({ headers: { ...route.request().headers(), 'Authorization': 'token' } }))page.waitForRequest('/api/').then(req => req.setHeader('Authorization', 'token'))page.setExtraHTTPHeaders({ Authorization: 'token' }) applies to route handlers automatically6.What does page.on('request') do compared to page.route()?page.on('request') intercepts and can block the request; page.route() only observes itpage.on('request') observes requests without affecting them; page.route() intercepts and lets you fulfill, abort, or continueThey are identical — both intercept and modify requestspage.on('request') only works for XHR; page.route() works for all resource types7.You want to record all network traffic during a complex checkout flow and replay it in CI without a real backend. Which Playwright feature supports this?page.on('response') with fs.writeFileSync() to save each responsepage.route() with route.fulfill() for every possible URLpage.routeFromHAR() — record with update: true, then replay with update: falsecontext.setOffline(true) to simulate no network8.What is the difference between using page.route() and context.route() for request interception?context.route() is faster because it runs at the network levelpage.route() applies only to that page; context.route() applies to all pages (tabs) created in the same browser contextcontext.route() can only block requests; page.route() can fulfill themThey are identical — context is just an alias for page in this contextSubmit answersarrow-left PreviousGlobal setup and teardownMock APIsNext arrow-right