-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProductListingPage.java
More file actions
34 lines (27 loc) · 990 Bytes
/
ProductListingPage.java
File metadata and controls
34 lines (27 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package pages;
import org.openqa.selenium.*;
import java.util.*;
public class ProductListingPage {
WebDriver driver;
public ProductListingPage(WebDriver driver) {
this.driver = driver;
}
By products = By.cssSelector(".ProductCard_card__1fjfq");
By sortDropdown = By.cssSelector("select[name='sort']");
By brandFilter = By.xpath("//input[@type='checkbox' and contains(@name, 'brand')]");
public void sortBy(String sortOption) {
driver.findElement(sortDropdown).sendKeys(sortOption);
}
public List<WebElement> getDisplayedProducts() {
return driver.findElements(products);
}
public void applyBrandFilter(String brand) {
List<WebElement> filters = driver.findElements(brandFilter);
for (WebElement filter : filters) {
if (filter.getAttribute("name").contains(brand)) {
filter.click();
break;
}
}
}
}