# Selenium

[**Selenium**](https://www.selenium.dev/) is a tool that helps automate web browser interactions for website testing and more.

To integrate Selenium with Oxylabs [**Residential Proxies**](https://oxylabs.io/products/residential-proxy-pool), follow the instructions below or watch this video tutorial:

{% embed url="<https://www.youtube.com/watch?v=uh71blwf1l0>" %}

**Step 1.** Install [**Selenium Wire**](https://github.com/wkeeling/selenium-wire) to extend Selenium's Python bindings because using the default Selenium module for implementing proxies that require authentication makes the whole process complicated. You can do it using the `pip` command: `pip install selenium-wire`

Another recommended package for this integration is `webdriver-manager`. It's a package that simplifies the management of binary drivers for different browsers. In this case, **there's no need to manually download a new version of a web driver after each update**.

You can install the `webdriver-manager` using the `pip` command as well: `pip install webdriver-manager`

**Step 2.** Specify your account credentials for proxies to work:

`USERNAME = "your_username"`

`PASSWORD = "your_password"`

`ENDPOINT = "pr.oxylabs.io:7777"`

You'll need to adjust`your_username` and `your_password` fields with the username and password of your proxy user.

{% hint style="info" %}
You can create and manage your proxy users in our [**dashboard**](https://dashboard.oxylabs.io/en/)**.**
{% endhint %}

**Step 3**. Check if the proxy is working by visiting [**ip.oxylabs.io**](https://ip.oxylabs.io/). If everything is working correctly - it will return an IP address of a proxy you're using.

```
try:
    driver.get("https://ip.oxylabs.io/")
    return f'\nYour IP is: {driver.find_element(By.CSS_SELECTOR, "pre").text}'
finally:
    driver.quit()
```

Complete code for Oxylabs' [**Residential Proxies**](https://oxylabs.io/products/residential-proxy-pool) integration with Selenium:

```
from selenium.webdriver.common.by import By
from seleniumwire import webdriver
# A package to have a chromedriver always up-to-date.
from webdriver_manager.chrome import ChromeDriverManager

USERNAME = "your_username"
PASSWORD = "your_password"
ENDPOINT = "pr.oxylabs.io:7777"

def chrome_proxy(user: str, password: str, endpoint: str) -> dict:
    wire_options = {
        "proxy": {
            "http": f"http://{user}:{password}@{endpoint}",
            "https": f"https://{user}:{password}@{endpoint}",
        }
    }

    return wire_options

def execute_driver():
    options = webdriver.ChromeOptions()
    options.add_argument('--headless')
    proxies = chrome_proxy(USERNAME, PASSWORD, ENDPOINT)
    driver = webdriver.Chrome(
    ChromeDriverManager(driver_version='<VERSION>').install(), options=options, seleniumwire_options=proxies
    )
    try:
        driver.get("https://ip.oxylabs.io/")
        return f'\nYour IP is: {driver.find_element(By.CSS_SELECTOR, "pre").text}'
    finally:
        driver.quit()


if __name__ == '__main__':
    print(execute_driver())
```

If you want to learn more about web scraping with Selenium, read our [**blog post**](https://oxylabs.io/blog/selenium-web-scraping).

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


---

# 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/integrations/proxy-integrations/residential-proxies-guides/selenium.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.
