# Firefox (Legacy)

A Firefox-based browser environment can be tested when Chrome environment fails to provide acceptable results. Firefox environment evades bot detection through built-in modifications and automatic proxy integration.

{% hint style="info" %}
The Firefox endpoint supports **two Playwright versions**: **1.51** and **1.56**. Other versions are not supported. You can specify the Playwright version via the `o_pw` parameter, for example:

`wss://USER:PASS@ubs.oxylabs.io?o_pw=1.56`&#x20;
{% endhint %}

## Connection details

Connect to UBS using the following WebSocket endpoint:

```
wss://ubs.oxylabs.io
```

## Important considerations

* Requires explicit use of the `firefox` implementation in automation libraries
* May require minor adjustments compared to Chrome-based solutions

## Basic usage

{% tabs %}
{% tab title="Python" %}

```python
from playwright.sync_api import sync_playwright

username = "your-username"
password = "your-password"
endpoint = "ubs.oxylabs.io"
browser_url = f"wss://{username}:{password}@{endpoint}"

with sync_playwright() as p:
    browser = p.firefox.connect(browser_url, timeout=60000)
    page = browser.new_page()
    page.goto('https://example.com')
    browser.close()
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const { firefox } = require('playwright');

(async () => {
    const username = 'your-username';
    const password = 'your-password';
    const endpoint = 'ubs.oxylabs.io';
    const browserUrl = `wss://${username}:${password}@${endpoint}`;

    const browser = await firefox.connect(browserUrl, { timeout: 60000 });
    const page = await browser.newPage();
    await page.goto('https://example.com');
    await browser.close();
})();
```

{% endtab %}
{% endtabs %}

## United States proxy infrastructure

Users, who mainly operate in the US, can connect directly to US-based infrastructure via the special entry point. This ensures faster loading time and better browsing efficiency. To establish connection, select the following:

```
wss://ubs-us.oxylabs.io
```

Code examples:

{% tabs %}
{% tab title="Python" %}

```python
from playwright.sync_api import sync_playwright

username = "your-username"
password = "your-password"
endpoint = "ubs-us.oxylabs.io"
browser_url = f"wss://{username}:{password}@{endpoint}"

with sync_playwright() as p:
    browser = p.firefox.connect(browser_url, timeout=60000)
    page = browser.new_page()
    page.goto('https://example.com')
    browser.close()
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const { firefox } = require('playwright');

(async () => {
    const username = 'your-username';
    const password = 'your-password';
    const endpoint = 'ubs-us.oxylabs.io';
    const browserUrl = `wss://${username}:${password}@${endpoint}`;

    const browser = await firefox.connect(browserUrl, { timeout: 60000 });
    const page = await browser.newPage();
    await page.goto('https://example.com');
    await browser.close();
})();
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Note:** this solution primarily shortens the response time for the US-based users, and should not be confused with proxy geo-location selection. More on that in the following section.&#x20;
{% endhint %}

## Country selection

You can specify a country for your browser session by adding the `?p_cc` parameter to your connection URL. Here are examples:

{% tabs %}
{% tab title="Python" %}

```python
from playwright.sync_api import sync_playwright

username = "your-username"
password = "your-password"
endpoint = "ubs.oxylabs.io"
country = "US"  # Replace with desired country code
browser_url = f"wss://{username}:{password}@{endpoint}?p_cc={country}"

with sync_playwright() as p:
    browser = p.firefox.connect(browser_url, timeout=60000)
    page = browser.new_page()
    page.goto('https://example.com')
    browser.close()
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const { firefox } = require('playwright');

(async () => {
    const username = 'your-username';
    const password = 'your-password';
    const endpoint = 'ubs.oxylabs.io';
    const country = 'US';  // Replace with desired country code
    const browserUrl = `wss://${username}:${password}@${endpoint}?p_cc=${country}`;

    const browser = await firefox.connect(browserUrl, { timeout: 60000 });
    const page = await browser.newPage();
    await page.goto('https://example.com');
    await browser.close();
})();
```

{% endtab %}
{% endtabs %}

If no country is specified, the system will automatically assign one based on availability.


---

# Agent Instructions: 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:

```
GET https://developers.oxylabs.io/scraping-solutions/headless-browser/firefox.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
