|
| 1 | +package demo.customassert; |
| 2 | + |
| 3 | +import Drivers.DriverManager; |
| 4 | +import org.openqa.selenium.By; |
| 5 | + |
| 6 | +public class ProductPage { |
| 7 | + |
| 8 | + private static final By PRODUCT_NAME = By.xpath("//div[contains(@class,'entry-content content-title')]/h1"); |
| 9 | + private static final By PRODUCT_CODE = By.xpath("//span[text()='Product Code:']/following-sibling::span"); |
| 10 | + private static final By PRODUCT_BRAND = By.xpath("//span[text()='Brand:']/following-sibling::a"); |
| 11 | + private static final By PRODUCT_AVAILABILITY = By.xpath("//span[text()='Availability:']/following-sibling::span"); |
| 12 | + private static final By CART_COUNT = By.xpath("//div[contains(@class,'flex-wrap')]//span[contains(@class,'cart-item-total')]"); |
| 13 | + |
| 14 | + public static ProductPage getProductPage() { |
| 15 | + return new ProductPage(); |
| 16 | + } |
| 17 | + |
| 18 | + public void loadProductPage(){ |
| 19 | + DriverManager.getDriver().get("https://ecommerce-playground.lambdatest.io/index.php?route=product/product&product_id=40&search=iphone"); |
| 20 | + } |
| 21 | + |
| 22 | + public ProductPageValidator getValidator() { |
| 23 | + return ProductPageValidator.builder() |
| 24 | + .productBrand(getProductBrand()) |
| 25 | + .productName(getProductName()) |
| 26 | + .productCode(getProductCode()) |
| 27 | + .productAvailability(getProductAvailability()) |
| 28 | + .cartCount(Integer.valueOf(getCartCount())).build(); |
| 29 | + } |
| 30 | + |
| 31 | + public String getProductName() { |
| 32 | + return DriverManager.getDriver().findElement(PRODUCT_NAME).getText(); |
| 33 | + } |
| 34 | + |
| 35 | + public String getProductCode() { |
| 36 | + return DriverManager.getDriver().findElement(PRODUCT_CODE).getText(); |
| 37 | + } |
| 38 | + |
| 39 | + public String getProductBrand() { |
| 40 | + return DriverManager.getDriver().findElement(PRODUCT_BRAND).getText(); |
| 41 | + } |
| 42 | + |
| 43 | + public String getProductAvailability() { |
| 44 | + return DriverManager.getDriver().findElement(PRODUCT_AVAILABILITY).getText(); |
| 45 | + } |
| 46 | + |
| 47 | + public String getCartCount() { |
| 48 | + return DriverManager.getDriver().findElement(CART_COUNT).getText(); |
| 49 | + } |
| 50 | +} |
0 commit comments