Example3 -Parameterization

@Tc03

Scenario: Item Counting

Given I am in Ebay Shopping Homepage

When I am seaching for 'iphone13'

Then I am validating the itemcount atleast 1500

@Tc04

Scenario: Item Counting

Given I am in Ebay Shopping Homepage

When I am seaching for 'samsungs24'

Then I am validating the itemcount atleast 3000


=====================================================


package StepDefinations;


import static org.testng.Assert.fail;



import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;


import org.testng.Assert;


import io.cucumber.java.en.Given;

import io.cucumber.java.en.Then;

import io.cucumber.java.en.When;


public class FlipKartSteps {


WebDriver driver;

public FlipKartSteps(FlipKartCommonSteps commonsteps) {

this.driver=commonsteps.getDriver();

}

@Given("I am in Ebay Shopping Homepage")

public void i_am_in_ebay_shopping_homepage() throws InterruptedException {

driver.get("https://www.ebay.com/");

Thread.sleep(1000);

}


@When("I am seaching for {string}")

public void i_am_seaching_for(String str1) {

driver.findElement(By.id("gh-ac")).sendKeys(str1);

driver.findElement(By.className("gh-search-button__label")).click();

}


@Then("I am validating the itemcount atleast {int}")

public void i_am_validating_the_itemcount_atleast(Integer minCount) {

String strCount =driver.findElement(By.cssSelector("div[class='srp-controls__control srp-controls__count'] span:nth-child(1)")).getText().trim();

int actualCount=Integer.parseInt(strCount.replace(",", ""));

if (actualCount < minCount) {

fail("Item count is less than expected. Found: " + actualCount + ", Expected: " + minCount);

}

}


}


===========================================

package TestNGRunnerFiles;


import org.junit.runner.RunWith;


import io.cucumber.junit.Cucumber;

import io.cucumber.junit.CucumberOptions;


@RunWith(Cucumber.class)

@CucumberOptions(

features = "src/test/java/FeatureFiles",

glue = {"StepDefinations"},

monochrome = true,

tags = "@Tc03 or @Tc04",

dryRun = false,

plugin = {"pretty", "html:target/cucumber-report.html"}

)

public class FlipKartTestRunner {


}