.feature
files) to actual automation code (usually written in Java)..feature
file.Create step definition folder
src/test/java
rightclick
new --->> project ---> Steps
Feature: Credit Card Payment
Scenario Outline: Make a payment with different options
Given the user is on the credit card payment page
When the user fills in all details and selects the "<Payment Option>"
And the user clicks on the "Pay" button
Then the credit card confirmation page should be displayed
=====================
package Steps;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.When;
import io.cucumber.java.en.Then;
public class Ebay_homeSteps {
@Given("the user is on the credit card payment page")
public void user_is_on_credit_card_payment_page() {
System.out.println("Navigating to credit card payment page...");
// Code to launch browser and go to payment page
}
@When("the user fills in all details and selects the {string}")
public void user_fills_in_details_and_selects_option(String paymentOption) {
System.out.println("Filling in details and selecting payment option: " + paymentOption);
// Code to fill form and select the given payment option
}
@When("the user clicks on the {string} button")
public void user_clicks_on_button(String buttonName) {
System.out.println("Clicking on button: " + buttonName);
// Code to click the Pay button
}
@Then("the credit card confirmation page should be displayed")
public void confirmation_page_should_be_displayed() {
System.out.println("Verifying confirmation page...");
// Code to verify the confirmation page is displayed
}
}