Selenium Logo

Selenium is great for Automated Testing - I thought I’d revisit my old testing tools and so this is an update for 2020 to cover basics of installing Selenium, Geckodriver (for testing Firefox) with Python on a Mac.

Previously, my testing was done in Selenium IDE but you really need to automate this for cross-browser testing which is why you’ll need to download and install Selenium on your Mac.

I’ll guide you to

  • install the software that you need
  • create a basic test from your terminal

Download Geckodriver to your Mac

You can head over to the Geckodriver project page and download the latest package or you can use Homebrew. Install ChromeDriver with brew cask install geckodriver

  1. Next we need the latest Python. I’m using a brand new 2020 Macbook Air and it has the out of date v2.x installed so go ahead and install the latest 3.x with: Brew install Python

As a note you now (probably) have both Python2 and Python3 on your Mac - so we are going to use Python3

  1. Now you can install Selenium with: Pip3 install -U selenium

Pip3 is the package install manager for Python3

Basic Test Case for Geckodriver and Selenium

Having completed these steps, you can now run a basic test - you need to have Firefox installed on your mac for this to work

Open a terminal window and enter python3 to start Python …

1
2
3
4
Python 3.8.3 (v3.8.3:6f8c8320e9, May 13 2020, 16:29:34) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Type the following, pressing enter at the end of each line

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("https://www.damien.co")

After a few seconds, if all is well a new instance of Firefox will open

To exit Python from your open Terminal, type exit() and press enter

Did you find this helpful? Please let me know