Skip to content

Playwright

What is Playwright?

Playwright, built by Microsoft, is a Node.js library that automates websites and web applications running on Chromium, Firefox, and WebKit through a single API. Developers writing JavaScript code can use these APIs to create new browser pages, navigate to URLs, and interact with elements on the page. Additionally, Playwright can automate Microsoft Edge because it is built on the open source Chromium web platform.

Here's how to integrate Socks5 with Playwright.

1

Install Playwright

First install Playwright using npm, yarn, or pnpm. Alternatively, you can use the VS Code extension to get started and execute tests.

Click hereView detailed installation tutorial

2

Fill in the proxy value in Playwright

Server: proxy-as.socks5.io:3000

Agent Account: socks5-customer-USERNAME

Agent password: PASSWORD

Code Example:

const playwright = require('playwright');
(async () => {
    for (const browserType of ['chromium', 'firefox', 'webkit']) {
        const browser = await playwright[browserType].launch({
            headless: false,
            proxy: {
                server: 'http://proxy-as.socks5.io:3000',
                username: 'socks5-customer-USERNAME',
                password: 'PASSWORD'
            },
        });
        const context = await browser.newContext();
        const page = await context.newPage();
        await page.goto('https://ip234.in/ip.json');
        await page.screenshot({ path: `${browserType}.png` });
        await browser.close();
    }
})();