Using Behave and Selenium WebDriver in Python

Behave is a BDD framework available in Python. It provides a very similar approach to Cucumber.

In this recipe, we will see how to use Behave and Selenium WebDriver to test a fund transfer application.

Getting ready

You need to install Behave using the following command:

pip install behave

How to do it...

In Behave, we need to create a features file for the stories under test. These stories are written in the Gherkin language with the Given, When, and Then structures in the Cucumber format. Perform the following steps to create a feature and step definition file with Behave:

  1. Create a folder named fundtransfer and then create two subfolders, features and steps, in the fundtransfer folder.
  2. In the feature folder, ...

Get Selenium Testing Tools Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.