Best Python code snippet using playwright-python
test_interception.py
Source:test_interception.py
...201 elif is_firefox:202 assert failed_request.failure == "NS_ERROR_OFFLINE"203 else:204 assert failed_request.failure == "net::ERR_INTERNET_DISCONNECTED"205async def test_page_route_should_send_referer(page, server):206 await page.set_extra_http_headers({"referer": "http://google.com/"})207 await page.route("**/*", lambda route: route.continue_())208 [request, _] = await asyncio.gather(209 server.wait_for_request("/grid.html"),210 page.goto(server.PREFIX + "/grid.html"),211 )212 assert request.getHeader("referer") == "http://google.com/"213async def test_page_route_should_fail_navigation_when_aborting_main_resource(214 page, server, is_webkit, is_firefox215):216 await page.route("**/*", lambda route: route.abort())217 with pytest.raises(Error) as exc:218 await page.goto(server.EMPTY_PAGE)219 assert exc...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!