How to set up a proxy in Playwright

Until recently, cross-browser testing of web applications was a time-intensive process. It required manually verifying software functionality across each browser engine, often necessitating the use of separate tools. The introduction of Playwright has significantly streamlined this process.

Playwright is a Node.js-based plugin specifically designed for automating cross-platform testing. It aids web developers in efficiently conducting tests across different browsers.

Integrating a proxy into development and testing tools like Playwright can optimize the testing process. It helps in bypassing blocks and filters, and enhances data protection and confidentiality during testing.

Video tutorial for proxy configuration in Playwright

Setting up a proxy in Playwright for online testing

Follow these steps to set up a proxy in Playwright:

  1. After installing Playwright, locate the playwright.config.ts file in the installation directory and open it with any code editor.
  2. Integrate a proxy configuration by adding the following code structure:
  3. proxy: {





  4. In the server field, input your proxy's IP address and port, separated by a colon. If using private proxies, fill in the username and password fields with your credentials. For free proxies, leave these fields blank.
  5. 1.png

For managing IP addresses in Playwright with Python follow these steps:

  1. Import the “async_playwright” and “asyncio” modules in your Python script.
  2. 2.jpg

  3. Define a function and set the proxy parameters with the code snippet:
  4. proxy={

    'server': "ip-address:port",



    It should be indicated like displayed on the screenshot:


  5. Include authentication details - username and password for private proxies by adding new strings:
  6. 'username': 'your username',

    'password': ‘your password',


  7. To implement proxy rotation, add a pool of IP addresses to your code:
  8. proxy_pool = [

    {"server": "ip-address:port", "username": "your username", "password": "your password"},


    Repeat the server line as needed to include multiple IP addresses.


Playwright supports SOCKS, HTTP, and HTTPS protocols. The choice of proxy depends on the protocol of the target site to which the request is sent. This setup ensures enhanced security and efficiency in your web testing process.