How do I set up Selenium Python?
Hi Alex,
You can install Selenium using pip (pip install selenium
), download the appropriate WebDriver (e.g., ChromeDriver), and write your test scripts in Python.
To set up Selenium Python and get started with Selenium Python testing, check out this blog:
If you want a containerized environment for Selenium, you can use Docker to set up Selenium Grid with browsers like Chrome or Firefox. Here’s how:
- Install Docker from Docker’s website.
- Pull the Selenium Docker image: docker pull selenium/standalone-chrome
- Run the Selenium container:
docker run -d -p 4444:4444 selenium/standalone-chrome
- In your Python script, use the remote WebDriver to interact with the Selenium server:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote(
command_executor='http://localhost:4444/wd/hub',
desired_capabilities=DesiredCapabilities.CHROME)
driver.get("https://www.example.com")
print(driver.title)
driver.quit()