Directions for Basic Testing Tool Installation

iconDiagram

A couple weeks ago we began the discussion of Automating Web Browser Tests. Today we want to share with you the basic steps to getting some automation testing tools installed.

Without further ado, let’s get into some more details about these tools and learn how you can also have this set up in your environment. Preferably, you would want to install these tools in a Linux environment for a better and more efficient way of working. Linux makes the installation of these tools pretty straightforward for users and we will be reviewing a step by step installation guide today that should have you up and running in no time. We will be installing: Selenium Web Driver, Behave, and all the dependencies that come with these tools in an Ubuntu environment.

Install Selenium Webdriver:

            sudo apt-get -y install python python-pip

            sudo pip install selenium

Install behave:

            sudo pip install behave

Install pyhamcrest (dependency):

            sudo pip install pyhamcrest

Install pyvirtualdisplay and xvfb: (to run headless tests)

sudo pip install pyvirtualdisplay

sudo apt-get -y install xvfb

Install the browser of your choice: Firefox, Chrome, IE

Note: Make sure to check that the browser you are running is compatible with the version of Selenium you are running.

You can take these tools a step further by integrating them with another automation tool: Jenkins.

You can have Jenkins run your tests nightly after builds or on demand at any given time. This makes the process of running your test suites a lot smoother. Tests will be running on a regular basis to ensure that your site is running smooth as it should be. In order to run your tests from Jenkins, you will need to make use of the pyvirtudisplay to provide Jenkins with a “virtual” browser window to run your test in.

Behave Framework is made up of three components: project.feature, project.py, and environment.py. The project directory tree typically would look like this:

project/

├── environment.py

└── features

 |      └── project.feature

└── steps

        └── project.py

The project.feature is your feature file which contains the “Given When Then” formula using the language Gherkin as a template for your tests and holds your behavior scenarios in it. The project.py is your step file which contains all your Python step implementations for the scenarios you have stated in your feature file. And finally, the environment.py is your environment file which gives you environmental controls over your tests allowing you to do actions before and after all steps, scenarios, and features.

If you are already familiar with writing unit tests or Selenium, tests like this may be an easy pickup for you. All you have to do now is implement Behave Framework into your tests and learn to make use of the behavior driven testing style of Behave. If you are not familiar with writing these type of tests, you can start by heading over to Behave’s official documentation site. There you can see examples and tips on how to get started.