Feature: Item count check in Ebay
@Par5
Scenario: Multiple Filters in Advanced Search Page
Given I am in Ebay Shopping Homepage
When I advanced search on items with multiple filters
| keyword | Exclude | min | max |
| iphone 11 | refurbished | 300 | 900 |
| iphone 13 | refurbished | 500 | 1000 |
| Samusung S24 | refurbished | 1000 | 5000 |
=======================
package Steps;
import static org.testng.Assert.fail;
import java.util.List;
import java.util.Map;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import io.cucumber.datatable.DataTable;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
public class ParameterSteps {
WebDriver driver;
public ParameterSteps(HookSteps hook_steps) {
this.driver=hook_steps.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 advanced search on items with multiple filters")
public void i_advanced_search_on_items_with_multiple_filters(DataTable dataTable1) throws InterruptedException {
driver.findElement(By.linkText("Advanced")).click();
List<Map<String, String>> rows= dataTable1.asMaps();
for (Map<String, String> row : rows) {
driver.findElement(By.xpath("//input[@id='_nkw']")).clear();
driver.findElement(By.xpath("//input[@id='_nkw']")).sendKeys(row.get("keyword"));
driver.findElement(By.xpath("//input[@id='_ex_kw']")).clear();
driver.findElement(By.xpath("//input[@id='_ex_kw']")).sendKeys(row.get("Exclude"));
driver.findElement(By.xpath("//input[@name='_udlo']")).clear();
driver.findElement(By.xpath("//input[@name='_udlo']")).sendKeys(row.get("min"));
driver.findElement(By.xpath("//input[@name='_udhi']")).clear();
driver.findElement(By.xpath("//input[@name='_udhi']")).sendKeys(row.get("max"));
Thread.sleep(1000);
driver.findElement(By.xpath("//div[@class='field adv-keywords__btn-help']//button[@type='submit'][normalize-space()='Search']")).click();
Thread.sleep(3000);
driver.navigate().back(); // To test next row in the loop
Thread.sleep(3000);
}
}}
================================
package testRunner;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
@CucumberOptions(features ="src/test/java/Features", glue = "Steps", tags = "@Par4 or @Par5", monochrome = true)
public class ParameterRunner extends AbstractTestNGCucumberTests {
}