circle-check
Documentation has been updated: see help center and changelog in one place.

Playwright

Integrate Playwright with Oxylabs Mobile Proxies for cross-browser automation.

Playwrightarrow-up-right is a Node.js library that lets you script and automates browsers using the same API, like Chrome, Firefox, and Safari. It is a convenient framework for automation and testing purposes.

To integrate Playwright with Oxylabs Mobile Proxies, follow the steps below:

Step 1. Install Node.js and a code editor of your choice. (Skip this step If you already have it)

Step 2. Create a Node.js project and install the required packages.

Step 3. Within Playwright, fill in the 'proxy' values:

Server: 'http://pr.oxylabs.io:7777'

circle-info

You can also use random or sticky country-specific entries. For example, if you enter http://us-pr.oxylabs.io:10000, you’ll acquire a US exit node. If you enter 10001 under port, you’ll receive the US exit node with a sticky session. You can find a complete list of country-specific random proxy entry nodes herearrow-up-right and a list of sticky proxy entry nodes - herearrow-up-right.

Username: 'Oxylabs' proxy user username'

Password: 'Oxylabs' proxy user password'

An example of a code looks like this:

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

And that's it! You've successfully integrated Oxylabs Mobile Proxies with Playwright.

If you want to learn more about web scraping with Playwright, read our blog postarrow-up-right.

Find the original Playwright integration blog post herearrow-up-right.

Last updated

Was this helpful?