Configure Eclipse with Cucumber

Components to be set up

1.Environment (Eclipse)
2.Feature File
3.StepDefinition File
4.Runner File

Cucumber Eclipse Plugin helps eclipse to understand the basic Gherkin syntax and it works like a syntax highlighter. It highlights all the main syntax
in the feature file which makes it more readable and clear. It also enables the run of the feature file independently.

Steps to follow:

1) Launch the Eclipse IDE and from Help menu, click “Install New Software”.
2) You will see a dialog window, click “Add” button.
3) Type name as you wish, let’s take “Cucumber” and type “” as location. Click OK.
4) You come back to the previous window but this time you must see Cucumber Eclipse Plugin option in the available software list. Just Check the box
and press “Next” button.
5) Click on Next.
6) Click “I accept the terms of the license agreement” then click Finish.
7) Let it install, it will take few seconds to complete.
8) You may or may not encounter a Security warning, if in case you do just click OK.
9) You are all done now, just Click Yes (It will restart).

Required Jars : Download from here 

Dependencies in Pom (MAVEN) :




This post cover maven based java webdriver BDD framework using cucumber for Google advance search scenario, Following are the steps to write scenario for BDD framework:
Step 1.  First create a maven eclipse project.

Step 2.Add above maven pom.xml file.Or click here.

Step 3. Create a feature “GoogleScenario.feature”  file and put into package “com/maven/test” of source folder “src/test/resources”.

Paste the below scenario in GoogleScenario.feature

Feature: Google Search

Scenario: Advance Search in Google

Given user is on google search page

When enter “testing” text into search field

And click on search button

And click on advance search icon

And click on advance search link

And click on advance search button

Then verify first link text “testing”

Step 4. Now need to create step definition file for above scenario and implement webdriver automation code. So Create a java file “” and put under into package “com/maven/test” of source folder” src/test/java” and write below code:

package com.maven.test;

import java.util.concurrent.TimeUnit;

import org.junit.Assert;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

import cucumber.annotation.*;

import cucumber.annotation.en.*;

public class GoogleStep {

protected WebDriver driver;


public void setUp() {

driver = new FirefoxDriver();

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);




public void tearDown() {



@Given(“user is on google search page”)

public void The_user_is_on_google_search_page() {



@When(“enter \”([^\”]*)\” text into search field”)

public void User_enters_text_into_field(String text) {



@And(“click on search button”)

public void user_click_on_search_button() {



@And(“click on advance search icon”)

public void click_on_advance_icon() {



@And(“click on advance search link”)

public void click_on_advance_link() {

driver.findElement(By.xpath(“//div[text()=\”Advanced search\”]”)).click();


@And(“click on advance search button”)

public void click_on_advance_button() {

driver.findElement(By.xpath(“//input[@value=’Advanced Search’]”)).click();


@Then(“verify first link text \”([^\”]*)\””)

public void verify_first_link_text(String msg)


WebElement message = driver.findElement(By.xpath(“//*[@id=’rso’]/li[1]/div/h3/a”));




Step 5. Now create “” which defines cucumber-jvm configuration and put under package “com/maven/test” of source folder” src/test/java”.

package com.maven.test;

import org.junit.runner.RunWith;

import cucumber.junit.Cucumber;


@Cucumber.Options(plugin= {“pretty”, “html:target/cucumber-htmlreport”,”json-pretty:target/cucumber-report.json”})

public class RunCukesTest {


Step 6.Now right click on the project and click on maven test.Or just run the ‘RunCukesTest’ class.

Step 7. You should see test will execute and after execution report is generated under directory “\target\cucumber-htmlreport”.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s