How to install selenium with python

Scott
4 min readApr 16, 2020

Download and use Chrome. If you already have Chrome, update it to the latest version.

Download ChromeDriver, download the latest one. To see what version of chrome you have, open up Chrome if you aren’t already using it (your browser, not chrome driver). Bring your mouse to the top left of your computer screen to the menu options, click on Chrome, then click on “About Google Chrome”.

Click on Chrome in the top left. Then about Google Chrome.
Your version is listed here.
Choose the option that corresponds with your computer.

Now open up terminal:

From the top right hand of your desktop, Click the spotlight magnifier.
Type Terminal in the spotlight window. Choose it

First install pip by typing or copying the following in Terminal then click enter: (if you don’t have pip already)

sudo easy_install pip

It may ask for your password, type your computer’s password. Click enter. When its done, the cursor will return.

Type or copy and paste the following in Terminal then click enter:

pip install selenium

Since we are in the terminal lets move chromedriver to a better location. Type or copy and paste the following line into terminal and click enter.

mv ~/Downloads/chromedriver /usr/local/bin

Download and install Pycharm CE, or visual studio download and install if you don’t have either.

Then open Pycharm if you have that.

Create new project.
Click create
Click close, unless you love distracting tips.
If you don’t see preferences for new projects, you might find it in “other settings”
Choose Python interpreter.
Then Choose an interpreter.

Choose Python 3. If you have Python 2. you should definitely update to Python 3.

Now, click the plus sign. It should be selectable after you choose an interpreter.

Search for and select selenium
Click the red button to close.
Click okay.
Right click your project (or control click with a magic mouse) and add a file.
Name it automation.py
Give it the name automation.py

When you use the .py file ending, the python interpreter knows to treat the text you write as Python code.

Type or paste the following code into your file.

from selenium import webdriver

Now type or copy the following code into your file:

driver = webdriver.Chrome("")
driver.get("https://www.google.com")

It should look something like this:

Now open up Finder.

Search for chromeDriver.

Right click on chromeDriver. Click ‘alt’ and then you can click on copy “chromedriver” as pathname

You can’t see it yet, but now you have copied the path to your chrome driver to your pasteboard.

Now go back to your code and paste the path you copied between the empty quotes:

driver = webdriver.Chrome("") # <- paste  between the quotes.
driver.get("https://www.google.com")

Now right click the empty space of your Pycharm file, anywhere under the code you wrote, and then choose run automation.

Wait a minute for chrome to open. Congrats you just ran an automated Script and opened Google with it!

--

--