Book Image

Selenium Testing Tools Cookbook

By : UNMESH GUNDECHA
5 (1)
Book Image

Selenium Testing Tools Cookbook

5 (1)
By: UNMESH GUNDECHA

Overview of this book

This book is an incremental guide that will help you learn and use the advanced features of the Selenium toolset including the WebDriver API in various situations to build a reliable test automation. You start off by setting up the test development environment and gain tips on the advanced locater strategy and the effective use of the Selenium WebDriver API. After that, the use of design patterns such as data - driven tests and PageFactory are demonstrated. You will then be familiarised with extending Selenium WebDriver API by implementing custom tasks and setting up your own distributed environment to run tests in parallel for cross-browser testing. Finally, we give you some tips on integrating Selenium WebDriver with other popular tools and testing mobile applications. By the end of this book, you will have learned enough to solve complex testing issues on your own.
Table of Contents (21 chapters)
Selenium Testing Tools Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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, create a plain text file named fundtransfer.feature, as follows:

    Feature: Customer Transfer's Fund
           As a customer,
           I want to transfer funds
           so that I can send money to my friends and family
    
    Scenario: Valid Payee
           Given...