Start Automation Quickly with Qxf2’s Framework using Cookiecutter

We came across Cookiecutter when working at a client. It is a tool that helps you create new projects based on templates. We decided to try it with our test automation framework. We have provided all the code used in this project on GitHub so that you can follow along.

What is Cookiecutter?

Cookiecutter is a command-line utility that creates projects from templates i.e. cookiecutters. Cookiecutter saves you lot of time which requires to modify all the stuff you need to do to start a new Project. We created a Cookiecuttter template for our test automation framework that is based on the page object model. The resulting framework template repository is here.  This repo is helpful for you to customize and set up Qxf2 framework for your project. Also, it will eliminate the need to manually edit various references which you will need when using our framework in your project.

How to setup Cookiecutter

Setup for Cookiecutter is very easy and simple. Just use the following command to install it.

pip install cookiecutter

How to generate Qxf2’s Page Object Model Framework Boilerplate quickly

Note: To use Cookiecutter for generating boilerplate of our Qxf2’s page object model, we recommend to get set up with python 3.7.x as our automation script is written for python 3.

To generate boilerplate you need to follow 2 steps:

Step 1: Traverse to the directory where you want to create a project. There are 2 ways to get the Qxf2 page object model template.

  1. Run the cookiecutter command, passing in the link to cookiecutter-pypackage’s HTTPS clone URL like this:
  2. Another approach would be to clone it to your local and run the cookiecutter below command:
    cookiecutter <path of the cloned repo>
    (For example – cookiecutter c:/code/Qxf2_POM_Template_using_Cookiecutter)

Step 2: After the above command is executed following parameters will be prompted to be filled

  1. directory_name [Qxf2_POM]: <Google Automation> ( Mention the project Directory name)
  2. project_url []:<> (Mention the project URL which you want to jumpon)
  3. page_object_name [tutorial_main_page]: <main_page> (Mention the first page object name)
  4. page_object_class_name [Tutorial_Main_Page]: <Main_Page> (Mention the same page object name but start with capital letter as shown the example)

Run sample test

For testing the generated boilerplate, switch to generated boilerplate and use the following command:
pytest -s -k current_url

This command will run the test and check if it landed on provided url by user. If test gets PASS without any error, it means the page object model is ready for automation and working fine.

Note: Before running the above command, you need to read the file present under generated boilerplate folder. Follow steps to setup with Qxf2 framework.


1. Cookiecutter documentation
2. Qxf2’s test automation framework

Leave a Reply

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