Selenium - All things

In order to work with Selenium for Python there are a few things you need to set up

  1. Install selenium using pip

  2. Download the web driver for the browser of your choice - you may need several if you need to ensure the app logic works across multiple browsers

Follow the steps below to ensure the two points above have been achieved

Great resource for Selenium learning is https://www.geeksforgeeks.org/selenium-python-tutorial/

 

Installing Selenium for Python

Simply execute the following command

pip install selenium

If you want to ensure that selenium is available to your project if the project is using something like Docker containers, add selenium to your requirements.txt file. For more information on this, visit https://www.geeksforgeeks.org/selenium-python-introduction-and-installation/

Installing the WebDriver ChromeDriver for Selenium

Begin by visiting the site https://chromedriver.chromium.org/ and navigate to ChromeDriver Documentation, select the link https://chromedriver.chromium.org/getting-started and read this page.

Back on https://chromedriver.chromium.org/ visit the Downloads links https://chromedriver.chromium.org/downloads, here you will find the available versions - download the appropriate version. In order to decide which version you need, in your Chrome browser select the three dots in the upper right of the browser

and navigate to “Help / About Google Chrome”

Make note of the version number

Create a new folder structure

Windows - c:\pf\bin, and add this path to your Windows PATH environment variable

linux - use the OS specific bin folders

Extract the contents of the downloaded ChromeDriver zip file into the specific bin folder

Fork this git project https://livingwater@bitbucket.org/living-water-js/getting-setup.git

Clone the project down, and from within the cloned project’s folder run the command py quick-demo.py

Use pytest -s <file name>

if you want to print to console whilst your tests are running