What is Playwright?

Playwright is a versatile Node.js toolkit for automating popular browsers in one go. Whether you’re scraping data, testing applications, or building seamless automation flows, Playwright’s unified interface and robust features help you get more done in less time—without compromising quality.

How to Integrate Bright Data With Playwright

Prerequisites

  1. Node.js: Download and install the latest version from nodejs.org.

  2. Playwright Package: Add Playwright to your project:

npm install playwright

Get Your Bright Data Credentials

Log in to your Bright Data dashboard and note the following details:

Host

Port

Username

Password

You’ll need these for proxy authentication.

Configure Playwright to Use Bright Data

  1. Set the Proxy Server: Include your Bright Data host and port in the browser launch options. Use the format host:port.

  2. Add Authentication: Provide your Bright Data username and password to ensure secure access.

Example Code

Use this example to get started:

const { chromium } = require('playwright');

(async () => {
  // Launch browser with proxy settings
  const browser = await chromium.launch({
    headless: false,  // Set to true for headless mode
    proxy: {
      server: 'http://[HOST]:[PORT]',  // Replace with your proxy host and port
      username: '[USERNAME]',        // Replace with your proxy username
      password: '[PASSWORD]'         // Replace with your proxy password
    }
  });

  const context = await browser.newContext();
  const page = await context.newPage();

  // Test the proxy by visiting an IP verification website
  await page.goto('http://httpbin.org/ip');
  // Capture a screenshot to verify the setup
  await page.screenshot({ path: 'example.png' });

  await browser.close();
})();

With Bright Data integrated into Playwright, your automation is both secure and discreet. Enjoy faster workflows, reduced detection risks, and greater peace of mind as you scrape, test, and automate online tasks.