top of page
Search
Writer's pictureIvan Ćorić

What is the Most Efficient Way to Set BDD Framework?

To create automation testing framework that could tests with business-readable specifications against test framework code on any modern development stack would be cucumber as said on their site.



What is Cucumber and What is Behavioral Driven Development?

The idea of cucumber developers become confirmed by users. And that is: business owners, analyses, project managers could write tests that could be automated with scripts written by Test Automation engineer. By simple steps Given, When, Then. So we will return to Cucumber in a second. First: what is Behavioral Driven Development. For that, I tried to quote Wikipedia page about BDD, but I become confused, and not sure if my perspective correct, so I will make simple as the cucumber is, and write it in human readable code (or words):

Behavioral Driven Development is simply to write behaving of the application first and then to develop it. Behaviour-Driven Development (BDD) is a set of practices that aim to reduce some common wasteful activities in software development. BDD aims to narrow the communication gaps between team members, a foster a better understanding of the customer and promote continuous communication with real-world examples.

What is Cucumber then? It is a tool that supports BDD. So you as business owner tell me as a tester: in Given condition of the user is on the login page, When user type username and password And click the Login button, Then the home page will load. Simple as that. So you are asking your self so what is a point of BDD testing if we already developed that part of the app. Well by human readable code, you will have a simplified overview of the automated testing process,


What is Python Behave?

So If you go to cucumber site you will see that for Python there is no official cucumber, and proposal is behave. So lets start:


Set your BDD project:


This project is about creating account and having questionnaire to fulfill before account is created: written in PyCharm and to make easier to write .feature files install plugin: Gherkin

Suggested tools:

Python version: Both 2.7.14 and 3.x.x are acceptable. (3.6 used) Framework: Behave (BDD) used with combination with Page Object Model (POM) Webdriver: ChromeWebDriver used

Requirements:

install package: behave in cmd/terminal type:

pip install behave

and selenium

pip install selenium

Webdriver:


The ChromeDriver controls the browser using Chrome's automation proxy framework. The server expects you to have Chrome installed in the default location for each system:

Download ChromeDriver on this link (version I am currently using is 2.41)

Set path of ChromeWebDirver:

For Linux:


Move the file to /usr/bin directory sudo mv chromedriver /usr/bin


Go to /usr/bin directory and you would need to run something like "chmod a+x chromedriver" to mark it executable.

For Windows:

Paste the chromedriver.exe file in "C:\Python\Scripts" Folder.

more detail on ChromeDriver wiki

Structure of the prject is:

. └── features ├── create_your_account.feature ├── questionnaire.feature ├── environment py ├── steps | ├── questionnaire_steps.py | └── crate_your_account_steps.py ├── pages | ├── questionnaire_page.py | └── crate_your_account_page.py └── base └── browser py

Here's a brief explanation of the files:

environment py: Define code to run before and after certain events during testing. (starts WebDriver) .feature: Written test for create account and login, with scenarios an steps.steps/: This is where Behave will initially look for the code for tests via decorators.pages/: Use locators in file and webDriver methods from browser py for implementing steps base/browser.py: Contains all webDriver actions wrapped to unique methods to make code reduced and easy to maintain.

To run test case open terminal in project root directory and type:


20 views

Recent Posts

See All

Comments


bottom of page