Selenium is a powerful open-source tool for automating web browsers. It supports multiple programming languages, including Python, Java, and C#
Selenium is a versatile open-source framework designed for browser automation. It supports various programming languages, such as Python, Java, and C#, making it a popular choice for web testing, data scraping, and automating repetitive tasks. Compatible with browsers like Chrome, Firefox, and Edge, Selenium provides powerful tools for interacting with web elements.
Before anything, check if Python is installed: Open a terminal (Command Prompt or shell) and type the following command:
python --version
If Python is installed, this will display the version number:
In this case please proceed to the next step:
Download Python from the official website: https://www.python.org/downloads/
Run the installer and make sure to check the option “Add Python to PATH” during installation.
Install Selenium and WebDriver:
Run this command to install Selenium:
pip install selenium
2. Run this command to install WebDriver:
pip install webdriver-manager
3. Create a project directory
mkdir selenium_project
4. Navigate to the newly created directory and create a subdirectory for scripts:
cd selenium_project
mkdir src
Open a text editor and paste your Selenium script:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
# Configure proxy with IP whitelisting
proxy = "http://gate.nodemaven.com:8080" # Replace with your proxy string
# Set Chrome options to use the proxy
chrome_options = Options()
chrome_options.add_argument(f"--proxy-server={proxy}")
# Initialize WebDriver
driver = webdriver.Chrome(
service=Service(ChromeDriverManager().install()),
options=chrome_options
)
try:
# Navigate to an IP-checking service
driver.get("https://www.maxmind.com/en/locate-my-ip-address")
print("Page title:", driver.title)
# Extract the IP address from the page (if displayed)
page_source = driver.page_source
print("Page content loaded. Check the browser to verify the proxy works.")
except Exception as e:
print("An error occurred:", e)
finally:
# Close the browser
driver.quit()
Save the file as selenium_test.py
inside the src
directory.
Open Command Prompt and navigate to the src
directory and then run the following command:
python selenium_test.py
As an expected output the browser will open, navigate to https://www.maxmind.com/en/locate-my-ip-address
, and display your IP address and related details.
The Command Prompt will print the page title:
Now you are ready to personalize your script and start using Selenium with NodeMaven proxies!
Achieve 95% High-Quality Connections with Reliable, Clean Proxy IPs
Flexible IP rotation per request or session
Carry Forward Unused Proxy Traffic
Maintain a Consistent IP for Up to 24 Hours for Stable Sessions
Get a Proxy Setup Tailored to Your Website and Unique Business Needs
Leverage a Premium Network of 30 Million+ High-Quality Residential IPs
Access IPs Across 150+ Countries and Major ISPs
Proxies help protect privacy, avoid IP bans, and enable access to geo-restricted content while automating tasks with Selenium.
Follow our simple guide to set up NodeMaven proxies in your Selenium scripts for enhanced automation.
Troubleshoot common problems like connection errors and proxy misconfigurations with our helpful solutions.
© 2024 Nodemaven. All rights reserved.
Illustrations by icons8.