> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nodemaven.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Playwright

> Set up Playwright with NodeMaven proxies and IP whitelisting.

Playwright is a Node.js library for automating web browsers, supporting tasks like UI testing, web scraping, form submissions, and page interactions. Playwright works with Chromium, Firefox, and WebKit browsers, and supports JavaScript, TypeScript, Python, and C#.

For more information, visit the [Playwright official website](https://playwright.dev/).

## Check whether Node.js is installed

Before anything, check whether Node.js is installed. Open a terminal (Command Prompt or shell) and run:

```bash theme={null}
node -v
```

If you get a version number, Node.js is already installed. The version number looks like this:

<Frame>
  <img src="https://downloads.intercomcdn.com/i/o/yvkc0rpk/1266292747/67585ef4dbc41afaad9c27618f07/P1.png" alt="Terminal showing the installed Node.js version number" />
</Frame>

In that case, skip ahead to Step 2 and install Playwright.

If Node.js is not installed on your system, you get this error instead:

```text theme={null}
'node' is not recognized as an internal or external command
```

If that is your case, continue with the steps below.

## Step 1: Install Node.js

<Steps>
  <Step title="Download Node.js">
    Go to the [Node.js official website](https://nodejs.org/) and download the **LTS version** for your operating system.

    <Frame>
      <img src="https://downloads.intercomcdn.com/i/o/yvkc0rpk/1266295386/bae75b56449d42c28a4c02c7fd92/p2.png" alt="Node.js download page with the LTS version highlighted" />
    </Frame>
  </Step>

  <Step title="Install Node.js">
    Run the installer you downloaded and follow the installation wizard.

    <Frame>
      <img src="https://downloads.intercomcdn.com/i/o/yvkc0rpk/1266295910/be45d67d1319b6aae06261d908f0/p3.png" alt="Node.js installation wizard" />
    </Frame>
  </Step>
</Steps>

## Step 2: Install Playwright

<Steps>
  <Step title="Run the installer">
    Install Playwright globally by running the following command:

    ```bash theme={null}
    npm init playwright@latest
    ```
  </Step>

  <Step title="Configure the project">
    Follow the prompts to configure the project, and make sure browsers are installed when prompted. The screenshot below is one example, but you can make your own choices.

    <Frame>
      <img src="https://downloads.intercomcdn.com/i/o/yvkc0rpk/1266309785/4d95fa1474dcfe29bc2a98f565c9/p1.png" alt="Playwright setup prompts in the terminal" />
    </Frame>

    After Playwright is installed, you get the following message:

    <Frame>
      <img src="https://downloads.intercomcdn.com/i/o/yvkc0rpk/1266314679/b3204ad098d82fdd919a09eb62da/p2.png" alt="Terminal message confirming Playwright was installed" />
    </Frame>
  </Step>
</Steps>

## Step 3: Create a project directory

Create a directory for your project and go to that location:

```bash theme={null}
mkdir playwright_nodemaven_project

cd playwright_nodemaven_project
```

Create and navigate to the subdirectory for scripts:

```bash theme={null}
mkdir src
cd src
```

## Step 4: Set up Playwright with a NodeMaven proxy

Create a new file called `playwright_ip_whitelist.js` in your `src` directory using your preferred text editor, then add the following code:

```javascript theme={null}
const { chromium } = require('playwright');

(async () => {
    const proxy = 'http://gate.nodemaven.com:8080'; // Replace with your proxy URL

    // Launch the browser with proxy settings
    const browser = await chromium.launch({
        proxy: { server: proxy },
    });

    const context = await browser.newContext();
    const page = await context.newPage();
    await page.goto('https://nodemaven.com/');
    console.log('Page title:', await page.title());

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

The script above uses [IP whitelisting](/residential-mobile/ip-whitelist), so replace the proxy URL with your own.

## Step 5: Run your script

Open Command Prompt, navigate to the `src` directory, and run:

```bash theme={null}
node playwright_ip_whitelist.js
```

The Command Prompt prints the page title:

<Frame>
  <img src="https://downloads.intercomcdn.com/i/o/yvkc0rpk/1266460763/ac68f538782d313784663809a801/p3.png" alt="Command Prompt showing the page title printed by the Playwright script" />
</Frame>

You are now ready to personalize your script and start using Playwright with NodeMaven proxies.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.