Posts

Showing posts from October, 2019

Cucumber Series Tutorial 3- Make your Automation Data Driven by Parametrising Feature File with Scenario Outline and Examples keyword.

Image
In Tutorial 2 we have seen, how to make test script data-driven by parametrizing the Feature file. But the problem with this approach is, if we have to supply multiple data then we have to write separate methods in step definition file, which will add a lot of boilerplate code. Another approach is using "Examples" Approach 2: Parametrising the Test script using Examples Keyword and Scenario Outline. Changes in Feature File: Here, instead of using Scenario , we will be using Scenario Outline And we will provide test data through Examples keyword: Feature: Free CRM Login Feature Scenario Outline: Free CRM Login Test Scenario Given User is already on Login Page When Title of login page is Free CRM Then user enters " <username> " and " <password> " And   User clicks on login button And user is on home page Examples:   | username | password |   | user1 | password1 |   | user2 | password2

Cucumber Series Tutorial 2- Make your Automation Data Driven by Parametrising Feature File

Image
We as automation engineers always require to design automation test script that runs for multiple datasets. Similarly, in Cucumber also, we can achieve data-driven testing. There are multiple ways to achieve data-driven testing, we will discuss each approach in detail. In this tutorial, we will discuss how to achieve Data-driven Testing by the Parametrising feature file. Approach 1: Parametrising Feature File In the Tutorial-1, we have hardcoded the username and password in the step definition file. Instead of hardcoding the username and password, we can parametrize them in Step definition file using regular expressions. Previous method: @Then ( "^User enters Username and password$" ) public   void  user_enters_Username_and_password() {   driver .findElement(By. xpath ( "//input[@name='email']" )).sendKeys( "username" );           driver .findElement(By. xpath ( "//input[@name='password']" )).sendKeys( "pa

Cucumber Series Tutorial 1

Image
Running & Setup Cucumber BDD based Test What is BDD? Behavior-driven development is a  collaborative  approach to software development that bridges the communication gap between business and IT.  In this, we are defining the behavior of Test Cases. Gherkin language is used to define the Behaviour in BDD.  It is a simple feature language. What is Cucumber? A cucumber is a tool that supports  Behaviour-Driven Development(BDD) . JBehave is also another tool for BDD Framework. Components of Cucumber : Feature File : extension is .feature. It's an executable specification written in plain text In this file Gherkin keywords like given, when, then, As, But, etc used. We create a Scenario for a specific feature. Step definition File :  Step definitions map (or “glue”) each Gherkin step to programming code to carry out the action that should be performed by the step.  We will be writing code. Using Java and Selenium. Test Runner : To run your feature, to gen