Cucumber — Step Definition | Code Factory

Donate : Link

WordPress Blog : Link

Applications… : Link

Cucumber Tutorial Index Page: Link

Feature: Login functionality feature
Scenario: Login functionality with valid data
Given Navigate to login page
When User logged in using username as "user1" and password as "user1
Then Home page should be display
public class stepDefinition {
WebDriver driver;

/* */
static {
/* System.setProperty("webdriver.gecko.driver", "<path to your gecko driver executable>"); */
System.setProperty("webdriver.gecko.driver", "C:\\Users\\CodeFactory\\Downloads\\geckodriver-v0.28.0-win64\\geckodriver.exe");

@Given("^Navigate to login page$")
public void navigate() {
driver = new FirefoxDriver();

@When("^User logged in using username as "user1" and password as "user1"$")
public void login() {

@Then("^Home page should be display$")
public void verifySuccessful() {
String expectedText = "Logout";
String actualText = driver.Findelement(By.linkText("Logout")).getText();
Assert.assertTrue("Login was successful", expectedText.equals(actualText));



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store