Getting Started

Introduction

In this series, we will setup an automation framework from scratch to test against the UI frontend of a web application.

The completed repository can be found at https://gitlab.com/testifyqa/python-web-selenium

We will use the following in our framework:

  • PyTest-BDD
    • pytest-bdd implements a subset of the Gherkin language to enable automating project requirements testing and to facilitate behavioural driven development.  Unlike many other BDD tools, it does not require a separate runner and benefits from the power and flexibility of pytest. It enables unifying unit and functional tests, reduces the burden of continuous integration server configuration and allows the reuse of test setups.
  • Selenium WebDriver
    • Selenium WebDriver is a collection of open source APIs which are used to automate the testing of a web application. It is a tool is used to automate web application testing on the UI level to verify that it works as expected. It supports many browsers such as Firefox, Chrome, IE, and Safari.

Setting Up Python

MacOS:

Install HomeBrew (Package Manager)

Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system.

  1. Go to https://brew.sh/
  2. Copy the command and paste it into Terminal…
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. Next, let’s insert the HomeBrew directory to the top of our PATH environment variable…
    export PATH="/usr/local/opt/python/libexec/bin:$PATH"
Install Python 3
  1. Open up Terminal and enter…
    brew install python
  2. We can check that a version of Python 3 has been installed with the following command…
    python -V

    If you experience any permission issues when installing, try the following command to change ownership of the folder where Python gets installed (make sure to change the 3.x version to match the one you are installing)…

    sudo chown -R $(whoami) /usr/local/lib/python3.x

Windows:

Install Chocolatey (Package Manager)

  1. Open up a command prompt (cmd.exe) with administrative privileges
  2. Enter in the following command…
    @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Install Python 3
  1. Open up a command prompt (cmd.exe) with administrative privileges again
  2. Enter in the following command…
    choco install python
  3. We can check that a version of Python 3 has been installed with the following command…
    python -V

When you install Python, it should also install its package manager pip. We can check pip is installed with the following command…

pip -V

Setting Up Your IDE

In this blog series, I will be using PyCharm Professional Edition. PyCharm also has a free community edition, however the community edition does NOT support BDD frameworks.

An alternative option is to use Visual Studio Code and then get the Python extension as well as any Cucumber and Gherkin extensions too.

As this is really down to personal choice, I won’t be going through step-by-step how to set up your IDE.

In the next section, we will create our virtual environment, install our project’s python packages and setup the initial folder / file structure 🙂

Liked it? Take a second to support Thomas on Patreon!

Next Article

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.