
Selenium Automation Testing With Cucumber Integration
Selenium is a Web Automation Tool and can be used to do regressive automated testing to test any web application.
Selenium is a power tool though it lacks an ability to bridge the gap between business analyst and technical personnel.
If we follow the old requirement gathering process and obsolete software life cycle then there are maximum chances of building a completely different product as to what client expected.
This happens because of mis-interpretations and Cucumber solves them all. Cucumber is BDD driven framework which test any application on the basis of its behaviour.
It uses Simple Gherkin language which is easy to understand and communication gap would be eliminated.
Video Courtesy : Execute Automation
In this video we will be talking about an introduction to Cucumber and also an high level introduction on BDD and Gherkin.
Prerequisites for using Cucumber
Before using Cucumber you should have some prerequisites in your system else Cucumber won’t run. Let’s see what those prerequisites are.
1. Selenium Jars.
2. Cucumber Jars : You can download from here. For other jars, just search in Maven repository and either you can download them or add their dependencies in your pom.xml. Following Jars are required:
Whatever tags you will be using in Feature file; you will have to use the same tags in the step definition file. In this way each scenario would be mapped with the test steps defined in the step definition file.
Selenium is a power tool though it lacks an ability to bridge the gap between business analyst and technical personnel.
If we follow the old requirement gathering process and obsolete software life cycle then there are maximum chances of building a completely different product as to what client expected.
This happens because of mis-interpretations and Cucumber solves them all. Cucumber is BDD driven framework which test any application on the basis of its behaviour.
It uses Simple Gherkin language which is easy to understand and communication gap would be eliminated.
Video Courtesy : Execute Automation
In this video we will be talking about an introduction to Cucumber and also an high level introduction on BDD and Gherkin.
Prerequisites for using Cucumber
Before using Cucumber you should have some prerequisites in your system else Cucumber won’t run. Let’s see what those prerequisites are.
1. Selenium Jars.
2. Cucumber Jars : You can download from here. For other jars, just search in Maven repository and either you can download them or add their dependencies in your pom.xml. Following Jars are required:
- cucumber-core
- cucumber-java
- cucumber-junit
- cucumber-jvm-deps
- cucumber-reporting
- gherkin
- junit
- mockito-all
- cobertura
- Create a Java Project with name “CucumberProject” in Eclipse.
- Add all jars what you have downloaded in earlier section.
- You can add Jars by clicking on Project -> Properties -> Java Build Path.
- Now, you are all set to start with Cucumber Feature File. One can make Feature file by first creating a features folder inside the Project. Now, you can create a file inside the folder “Features” with name as “FirstTest.feature”.
- Your first file is created and now you can start writing scenarios in it to test your web application.
- Now, you need a test runner to run the feature file because feature file can’t run by itself. First you have to make a RunnerTest Package and then create a testRunner.java class in it.
Also Read : 15 Top Selenium WebDriver Commands For Test AutomationAnnotations are used to start executing the test. @RunWith annotations helps in executing the test and @CucumberOptions annotations is used to set properties of your cucumber tests.
- Now your Feature file is ready and runner file as well. Now comes the test of actual implementation of the steps defined in the scenario. The file in which you will write the implementation of the steps of scenario is called Step Definition file.
- Given : This is used for a pre condition.
- When : This is used for an action which occurs after a pre condition.
- Then : This occurs for a reaction for an event.
- And: This adds a particular step in addition to the defined above.
- But : This adds a negative step.
Whatever tags you will be using in Feature file; you will have to use the same tags in the step definition file. In this way each scenario would be mapped with the test steps defined in the step definition file.
- Now comes the main step, how to run these files. You can run the feature files by right clicking on Test Runner file and click on “Run with” JUnit Test. When you will execute your test feature file you will observe that the Selenium test scripts start running and System.out.println is printing on the console.
Also Read : 10 Key Factors for Successful Test Automation


Mobile App Testing
Web App Testing
Game Testing
Automation Testing
Security Testing
Performance Testing
Selenium
Test Management
Usability Testing
Guides and Tutorials
Expert Insights
Software Testing Events
Load Testing
Performance Testing
Hire a Tester




