Playwright

What is Playwright?

Built by Microsoft, Playwright is a Node.js library that, with a single API, automates websites and web apps running on Chromium, Firefox, and WebKit. These APIs can be used by developers writing JavaScript code to create new browser pages, navigate to URLs, and then interact with elements on a page. In addition, since Microsoft Edge is built on the open-source Chromium web platform, Playwright can also automate Microsoft Edge.

Here's how to integrate Thordata with Playwright.

1

Installing Playwright

Get started by installing Playwright using npm, yarn or pnpm. Alternatively you can also get started and run your tests using the VS Code Extension.

Click here to view the detailed installation tutorial

2

Fill in the proxy value in Playwright

Server: t.pr.thordata.net:9999

Username: td-customer-USERNAME

Password: PASSWORD

Code Sample:

const playwright = require('playwright');
(async () => {
    for (const browserType of ['chromium', 'firefox', 'webkit']) {
        const browser = await playwright[browserType].launch({
            headless: false,
            proxy: {
                server: 'http://t.pr.thordata.net:9999',
                username: 'td-customer-USERNAME',
                password: 'PASSWORD'
            },
        });
        const context = await browser.newContext();
        const page = await context.newPage();
        await page.goto('https://ipinfo.thordata.com');
        await page.screenshot({ path: `${browserType}.png` });
        await browser.close();
    }
})();

Last updated

Was this helpful?