> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/integrations/proxy-integrations/playwright.md).

# Playwright

[**Playwright**](https://playwright.dev/) is a Node.js library that lets you script and automate browsers using the same API, like Chrome, Firefox, and Safari. It is a convenient framework for automation and testing purposes.&#x20;

Watch our video guide or follow the steps below to integrate Playwright with the following Oxylabs proxies:

* [**Residential & Mobile Proxies**](#residential-and-mobile-proxies)
* [**Datacenter Proxies**](#datacenter-proxies)
* [**Dedicated Datacenter Proxies (Enterprise)**](#dedicated-datacenter-proxies-enterprise)
* [**Dedicated Datacenter Proxies (Self-service)**](#dedicated-datacenter-proxies-self-service)
* [**ISP Proxies**](#isp-proxies)
* [**Dedicated ISP Proxies**](#dedicated-isp-proxies)

{% embed url="<https://youtu.be/KIsQ7ggB5DU>" %}

### **Step 1**

Install [Node.js](https://nodejs.org/en/download) 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.&#x20;

### **Step 3**

Within your Playwright script, fill in the `'proxy'` values as shown below:

```javascript
proxy: {
    server: 'protocol-host-port',
    username: 'USERNAME',
    password: 'PASSWORD'
},
```

Enter your `server` value according to your chosen Oxylabs proxy type:

* [Residential & Mobile Proxies](#residential-and-mobile-proxies)
* [Datacenter Proxies](#datacenter-proxies)
* [Dedicated Datacenter Proxies (Enterprise)](#dedicated-datacenter-proxies-enterprise)
* [Dedicated Datacenter Proxies (Self-service)](#dedicated-datacenter-proxies-self-service)
* [ISP Proxies](#isp-proxies)
* [Dedicated ISP Proxies](#dedicated-isp-proxies)

#### Residential & Mobile Proxies

```javascript
server: 'http://pr.oxylabs.io:7777' //protocol-host-port
```

**Protocol:** `http`, `https`, or `socks5h`

**Host:** `pr.oxylabs.io`

**Port:** `7777`

**Username:** `customer-USERNAME`

**Password:** `PASSWORD`

{% hint style="warning" %}
**Note:** Don't forget to add `customer-` prefix to your username.
{% endhint %}

You may also use **additional parameters** with residential and mobile proxies to set the geo-location (country, state, city, and etc.) and control sessions. Check out the [Residential Proxies documentation](/products/proxies/residential-proxies.md) to learn more.

#### Datacenter Proxies

```javascript
server: 'http://dc.oxylabs.io:8001' //protocol-host-port
```

**Protocol:** `http`, `https`, or `socks5h`

**Host:** `dc.oxylabs.io`

**Port:** `8001`

**Username:** `user-username`

**Password:** `password`

{% hint style="warning" %}
**Note:** Don't forget to add `user-` prefix to your username.
{% endhint %}

**Pay-per-IP subscription**

The port is the sequential number assigned to an IP address from the [proxy list](/products/proxies/datacenter-proxies/proxy-list.md). Thus, port `8001` uses the first IP address from your list. You may also enable [proxy IP rotation](/products/proxies/datacenter-proxies/ip-control.md) by setting the port to `8000`.

Furthermore, you can specify the [geo-location](/products/proxies/datacenter-proxies/select-country.md), for example, the US, by setting the **Proxy username** to `user-USERNAME-country-US`.

**Pay-per-traffic subscription**

The port `8001` picks a random IP address but stays consistent during a session. Alternatively, you can [rotate proxy IPs](/products/proxies/datacenter-proxies/ip-control.md) with each request by using port `8000`.

If you want to use a specific [geo-location](/products/proxies/datacenter-proxies/select-country.md), for example, the US, set the Proxy username to `user-USERNAME-country-US`.

#### Dedicated Datacenter Proxies (Enterprise)

```javascript
server: 'http://1.2.3.4:60000' //protocol-host-port
```

**Protocol:** `http`, or `socks5h`

**Host:** `1.2.3.4` (IP address from your [proxy list](/products/proxies/dedicated-datacenter-proxies/enterprise/proxy-lists.md))

**Port:** `60000` (HTTP), `1180` (SOCKS5)

**Username:** `username`

**Password:** `password`

For Enterprise Dedicated Datacenter Proxies (purchased through sales team), you’ll have to choose an IP address from the acquired [proxy list](/products/proxies/dedicated-datacenter-proxies/enterprise/proxy-lists.md).

#### Dedicated Datacenter Proxies (Self-service)

```javascript
server: 'http://ddc.oxylabs.io:8001' //protocol-host-port
```

**Protocol:** `http`, `https`, or `socks5h`

**Host:** `ddc.oxylabs.io`

**Port:** `8001`

**Username:** `user-username`

**Password:** `password`

{% hint style="warning" %}
**Note:** Don't forget to add `user-` prefix to your username.
{% endhint %}

For Self-Service Dedicated Datacenter Proxies (purchased through Oxylabs dashboard), the port indicates the sequential number of an IP address from the acquired [proxy list](/products/proxies/dedicated-datacenter-proxies/self-service/proxy-list.md). If you want to get a different IP with each request, change the Port to `8000` to enable [proxy rotation](/products/proxies/dedicated-datacenter-proxies/self-service/proxy-rotation.md).

#### ISP Proxies

```javascript
server: 'http://isp.oxylabs.io:8001' //protocol-host-port
```

**Protocol:** `http`, `https`, or `socks5h`

**Host:** `isp.oxylabs.io`

**Port:** `8001`

**Username:** `user-username`

**Password:** `password`

{% hint style="warning" %}
**Note:** Don't forget to add `user-` prefix to your username.
{% endhint %}

With ISP Proxies, the port is assigned to a specific IP address and its location. Hence, port `8001` will always pick the first IP from your [proxy list](/products/proxies/isp-proxies/proxy-list.md). If you want to get a different IP with each request, change the Port to `8000` to enable [proxy rotation](/products/proxies/isp-proxies/proxy-rotation.md).

#### Dedicated ISP Proxies

```javascript
server: 'http://disp.oxylabs.io:7777' //protocol-host-port
```

**Protocol:** `http`, `https`, or `socks5h`

**Host:** `disp.oxylabs.io`

**Port:** `8001`

**Username:** `user-username`

**Password:** `password`

{% hint style="warning" %}
**Note:** Don't forget to add `user-` prefix to your username.
{% endhint %}

You will need to choose the port assigned to an IP address from the purchased [proxy list](/products/proxies/dedicated-isp-proxies/self-service/proxy-list.md), which you can find on the Oxylabs dashboard. The `8001` port will pick the first IP address from your list for all requests. Use port `8000` for automatic [proxy IP rotation](/products/proxies/dedicated-isp-proxies/self-service/proxy-rotation.md).

### Full code sample

```javascript
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 proxies with Playwright. If you want to learn more about web scraping with Playwright, read our [blog post](https://oxylabs.io/blog/playwright-web-scraping).

Find the original Playwright integration blog post [here](https://oxylabs.io/resources/integrations/playwright).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/integrations/proxy-integrations/playwright.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
