Cucumber Java Selenium – Super Brief sum up

I am trying to sum up the whole thing using few Bullet points.

You need to create 3 files in Eclipse.

  1. Feature file
    1. CreateAccount.feature
    2. Login.Feature
    3. Feature: Login
      Description: This feature is to test the login functionalityScenario: Successful Login with Valid Credentials
      Given User is on Home Page
      When User enters Username and Password
      And Clicks Go button
      Then A message is displayed
  2. Step Definition File:
    public class TestingSteps {
     static WebDriver driver;
     static String URL;@Given("^User is on Home Page$")
     public void user_is_on_Home_Page() {
     System.setProperty("webdriver.gecko.driver", "H:\\somePath\\geckodriver.exe");
     WebDriver driver = new FirefoxDriver();
     URL = "";
    @When("^User enters Username and Password$")
     public void user_enters_UserName_and_Password() {
     WebElement loginLink = driver.findElement("login"));;
    WebElement emailField = driver.findElement(By.xpath("//div[@id='email']//input"));
    WebElement passwordField = driver.findElement(By.xpath("//div[@id='password']//input"));
     @When("^Clicks Go button$")
     public void clicks_Go_button() {
     WebElement goButton = driver.findElement("goButton"));;
     @Then("^A message is displayed$")
     public void a_message_is_displayed() throws Throwable {
     WebElement practicePage = driver.findElement("DrpDwn"));;
     System.out.println("Login Successful");
  3. JUnit Runner
    1. package tests;
      import org.junit.runner.RunWith;
      import cucumber.api.CucumberOptions;
      import cucumber.api.junit.Cucumber;
      public class TestRun {

      4. Right click on the TestRunner file and click on Run as Java Application.

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: