Best Python code snippet using playwright-python
test_proxy.py
Source:test_proxy.py
...13# limitations under the License.14import base6415import pytest16from playwright.async_api import Error17async def test_should_throw_for_bad_server_value(browser_factory):18 with pytest.raises(Error) as exc_info:19 await browser_factory(proxy={"server": 123})20 assert "proxy.server: expected string, got number" in exc_info.value.message21async def test_should_use_proxy(browser_factory, server):22 server.set_route(23 "/target.html",24 lambda r: (25 r.write(b"<html><title>Served by the proxy</title></html>"),26 r.finish(),27 ),28 )29 browser = await browser_factory(proxy={"server": f"localhost:{server.PORT}"})30 page = await browser.new_page()31 await page.goto("http://non-existent.com/target.html")...
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!!