Oxylabs and Playwright
avatar

Iveta Vistorskyte

Oct 22, 2021 2 min read

Playwright is a convenient framework for automation and testing purposes. It can work with web browser interactions, e.g., navigate to URLs, enter text, click buttons, extract text, and more. 

It works with the most popular browsers such as Google Chrome, Microsoft Edge using Chromium, Firefox, and Safari (when using WebKit.) Moreover, Playwright supports various programming languages such as Node.js, Python, Java, and .NET. This article covers the Playwright integration process with Oxylabs’ Residential Proxies.

How to integrate Oxylabs’ proxies with Playwright?

Before getting started with Playwright, you’ll need to install a few basic tools: Node.js and a code editor of your choice. After that, create a Node.js project and install the required packages. You may find a detailed guide on how to install and run Playwright on our blog post

Once everything is set up, we can move on to the next part – Oxylabs’ Residential Proxies integration with Playwright.

  • Within Playwright, fill in the ‘Proxy IP:Port’ in the ‘server’ value, for example:
http://pr.oxylabs.io:7777
  • Under ‘proxy’ value, input your Oxylabs’ proxy sub-user username in the ‘username’ value and your password.
  • The 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();
    }
})();

You can also use country-specific entries. For example, if you put us-pr.oxylabs.io under ‘host’ and 10001 under ‘port’, you’ll receive a US exit node with a sticky session. Please, check out our documentation for a complete list of country-specific entry nodes. 

And that’s it! You’ve successfully integrated Oxylabs’ Residential Proxies with Playwright.

Conclusion

In combination with Oxylabs’ Residential Proxies, Playwright might be a great tool when it comes to browser automation and web scraping.

If you have any questions about integrating Oxylabs’ proxies, you can contact us at any time. You should also visit our GitHub profile for more integrations with Oxylabs’ Proxies.

avatar

About Iveta Vistorskyte

Iveta Vistorskyte is a Content Manager at Oxylabs. Growing up as a writer and a challenge seeker, she decided to welcome herself to the tech-side, and instantly became interested in this field. When she is not at work, you'll probably find her just chillin' while listening to her favorite music or playing board games with friends.

All information on Oxylabs Blog is provided on an "as is" basis and for informational purposes only. We make no representation and disclaim all liability with respect to your use of any information contained on Oxylabs Blog or any third-party websites that may be linked therein. Before engaging in scraping activities of any kind you should consult your legal advisors and carefully read the particular website's terms of service or receive a scraping license.

Related articles

Aezakmi Proxy Integration With Oxylabs
Aezakmi Proxy Integration With Oxylabs

Nov 16, 2021

3 min read

What Is Affiliate Fraud and How to Prevent It?
What Is Affiliate Fraud and How to Prevent It?

Nov 12, 2021

9 min read

Proxy Integration With ParseHub
Proxy Integration With ParseHub

Nov 05, 2021

3 min read