Selenium
Integrate Selenium with Oxylabs Proxies for browser automation and more. Python and Java setup guides with code examples.
Selenium is a tool that helps automate web browser interactions for website testing and more.
Watch our video guide or follow the steps below to integrate Selenium Python or Java with the following Oxylabs proxies:
Residential & Mobile Proxies
Datacenter Proxies
Dedicated Datacenter Proxies (Enterprise)
Dedicated Datacenter Proxies (Self-service)
ISP Proxies
Dedicated ISP Proxies
Python setup
Setting up Selenium
Since using the default Selenium module for implementing proxies that require authentication makes the whole process complicated, install Selenium Wire to extend Selenium's Python bindings using pip:
Another recommended package for this integration is webdriver-manager. It's a package that simplifies the management of binary drivers for different browsers:
Proxy authentication
Specify your chosen proxy endpoint and account credentials in the following format:
Then adjust their values according to your chosen Oxylabs proxy type:
Residential & Mobile Proxies
Host: pr.oxylabs.io
Port: 7777
Username: customer-USERNAME
Password: PASSWORD
Note: Don't forget to add customer- prefix to your username.
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 to learn more.
Datacenter Proxies
Host: dc.oxylabs.io
Port: 8001
Username: user-username
Password: password
Note: Don't forget to add user- prefix to your username.
The port is the sequential number assigned to an IP address from the proxy list. Thus, port 8001 uses the first IP address from your list. You may also enable proxy IP rotation by setting the port to 8000.
Furthermore, you can specify the geo-location, for example, the US, by setting the Proxy username to user-USERNAME-country-US.
The port 8001 picks a random IP address but stays consistent during a session. Alternatively, you can rotate proxy IPs with each request by using port 8000.
If you want to use a specific geo-location, for example, the US, set the Proxy username to user-USERNAME-country-US.
Dedicated Datacenter Proxies (Enterprise)
Host: 1.2.3.4 (IP address from your proxy list)
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.
Dedicated Datacenter Proxies (Self-service)
Host: ddc.oxylabs.io
Port: 8001
Username: user-username
Password: password
Note: Don't forget to add user- prefix to your username.
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. If you want to get a different IP with each request, change the Port to 8000 to enable proxy rotation.
ISP Proxies
Host: isp.oxylabs.io
Port: 8001
Username: user-username
Password: password
Note: Don't forget to add user- prefix to your username.
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. If you want to get a different IP with each request, change the Port to 8000 to enable proxy rotation.
Dedicated ISP Proxies
Host: disp.oxylabs.io
Port: 8001
Username: user-username
Password: password
Note: Don't forget to add user- prefix to your username.
You will need to choose the port assigned to an IP address from the purchased proxy list, 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.
Testing the connection
Check if the proxy is working by visiting ip.oxylabs.io. If everything is working correctly - it will return an IP address of a proxy you're using.
Java setup
Prerequisites
Java Development Kit (JDK): Version 8 or higher (find newest version here).
Build Tool: Apache Maven (available here).
Java IDE: Any IDE or CLI supporting Maven.
Browser: Google Chrome installed locally (available here).
Initialize a standard Maven project in your preferred IDE or CLI before adding dependencies. After installing, you can verify your Java and Maven installations using the following lines:


Add dependencies
Add the following dependencies to your project's pom.xml file to include Selenium WebDriver, BrowserMob Proxy (for HTTP basic authentication), and WebDriverManager:
Add source code
Download the pre-configured proxy wrapper classes from the Oxylabs Selenium Java Repository and add them to your project's src/main/java directory:
ProxySetup.java: Stores your proxy endpoint parameters and account credentials.ProxyHelper.java: ManagesBrowserMobProxyServerinitialization, basic authentication, andChromeDriveroptions.ProxyDemo.java: Contains sample execution logic for standard and country-targeted proxy requests.
Configure proxies
Open ProxySetup.java and update the proxy details according to your chosen Oxylabs proxy type:
Residential & Mobile Proxies
Host: pr.oxylabs.io
Port: 7777
Username: customer-USERNAME
Password: PASSWORD
Note: Don't forget to add customer- prefix to your username.
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 to learn more.
Datacenter Proxies
Host: dc.oxylabs.io
Port: 8001
Username: user-USERNAME
Password: PASSWORD
Note: Don't forget to add user- prefix to your username.
The port is the sequential number assigned to an IP address from the proxy list. Thus, port 8001 uses the first IP address from your list. You may also enable proxy IP rotation by setting the port to 8000.
Furthermore, you can specify the geo-location, for example, the US, by setting the Proxy username to user-USERNAME-country-US.
The port 8001 picks a random IP address but stays consistent during a session. Alternatively, you can rotate proxy IPs with each request by using port 8000.
If you want to use a specific geo-location, for example, the US, set the Proxy username to user-USERNAME-country-US.
Dedicated Datacenter Proxies (Enterprise)
Host: 1.2.3.4 (IP address from your proxy list)
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.
Dedicated Datacenter Proxies (Self-service)
Host: ddc.oxylabs.io
Port: 8001
Username: user-USERNAME
Password: PASSWORD
Note: Don't forget to add user- prefix to your username.
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. If you want to get a different IP with each request, change the Port to 8000 to enable proxy rotation.
ISP Proxies
Host: isp.oxylabs.io
Port: 8001
Username: user-USERNAME
Password: PASSWORD
Note: Don't forget to add user- prefix to your username.
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. If you want to get a different IP with each request, change the Port to 8000 to enable proxy rotation.
Dedicated ISP Proxies
Host: disp.oxylabs.io
Port: 8001
Username: user-USERNAME
Password: PASSWORD
Note: Don't forget to add user- prefix to your username.
You will need to choose the port assigned to an IP address from the purchased proxy list, 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.
Execute the integration script
Execute ProxyDemo.java directly within your IDE, or compile and run the packaged JAR file using Maven via the terminal:
Upon execution, ProxyDemo initializes the driver, routes traffic through the specified Oxylabs endpoint via BrowserMob, and prints the resolved exit IP address.
However, you may need to install proper certificates to enable SSL support and avoid certificate-related warnings covered in the next step.
SSL Certificate Handling (optional)
The code uses BrowserMob Proxy, which supports full MITM. However, you may still see invalid certificate warnings.
Programmatic Bypass (Recommended)
Pass --ignore-certificate-errors via ChromeOptions in ProxyHelper.java to bypass SSL validation during automated execution.
Root Certificate Installation
Import the BrowserMob root certificate (ca-certificate-rsa.cer) into your operating system's trust store
macOS: Drag
ca-certificate-rsa.cerinto Keychain Access > System > Certificates, right-click, and select Always Trust.Windows: Double-click
ca-certificate-rsa.cer, select Install Certificate, and set the import destination to Trusted Root Certification Authorities.
If you want to learn more about web scraping with Selenium, read our blog post.
Find the original Selenium integration blog post here.
Last updated
Was this helpful?


