Selenium is great for Automated Testing - I thought I’d revisit my old testing tools and so this is an update for 2020 and covers the basics of installing Selenium, Chromedriver 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
Install the software
- You can head over to the Chromedriver Project page and download the latest package or you can use Homebrew. If you don’t have Homebrew, go install it.
Install ChromeDriver with
Brew cask install chromedriver
- 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
- Now you can install Selenium with:
Pip3 install -U selenium
Pip3 is the package install manager for Python3
Basic Test Case for Chromedriver and Selenium
Having completed these steps, you can now run a basic test - you need to have Chrome installed on your mac for this to work
Open a terminal window and enter
python3 to start Python …
Type the following, pressing enter at the end of each line
from selenium import webdriver driver = webdriver.Chrome() driver.get("https://www.damien.co")
After a few seconds, if all is well a new instance of Chrome will open
To exit Python from your open Terminal, type
exit() and press enter
Contact me today to find out how I can help you.