Next, you need to install Selenium. To do this, simply open up your Windows command prompt or Mac/Linux terminal and enter the command:
pip install selenium
Now that Selenium is installed, you need to pick a web browser for Selenium to use. Chrome and Firefox are both just as easy to use with Selenium, but here we’ll look at using Chrome. Assuming you have the Chrome browser installed on your machine, go to the following website:
Follow the link to the latest release and download the appropriate driver for your machine. Unzip the driver and move it to whatever place in your file system you prefer. Just keep in mind you will need to reference the chrome driver’s location when you use Selenium.
Finally, to make sure everything is working as it should, run this code:
from selenium import webdriver
# your executable path is wherever you saved the chrome webdriver
# in linux, something like chromedriver = '/home/grayson/Downloads/chromedriver'
chromedriver = r'C:\Users\grayson\Downloads\chromedriver.exe"
browser = webdriver.Chrome(executable_path=chromedriver)
url = 'https://www.duckduckgo.com'
If a Chrome browser pops up and takes you to DuckDuckGo’s home page, you’re all set!
If something’s not working, make sure Selenium, Chrome, and chrome driver are all up-to-date and try again. If all else fails, leave a comment and we’ll figure it out.