From af20c87fdccfab79ee0793be12888717b1ffa04c Mon Sep 17 00:00:00 2001 From: mrHewd Date: Sat, 28 Apr 2018 00:07:57 +0300 Subject: [PATCH] Added tests, pages --- src/test/java/AccountTest.java | 2 +- src/test/java/FeedbackTest.java | 59 ++++++++++++++++++++ src/test/java/FiltersTest.java | 48 +++++++++++++++- src/test/java/NavigationTest.java | 2 +- src/test/java/ProductsTest.java | 71 ++++++++++++++++++++++++ src/test/java/context/ChromeContext.java | 3 + src/test/java/page/AuthPage.java | 12 ++-- src/test/java/page/BasketPage.java | 37 ++++++++++++ src/test/java/page/FacebookPage.java | 8 --- src/test/java/page/FooterMenuPage.java | 11 +--- src/test/java/page/MainMenuPage.java | 3 - src/test/java/page/MainPage.java | 32 +++++++++-- src/test/java/page/OrderPage.java | 46 +++++++++++++++ src/test/java/page/ProductPage.java | 28 ++++++++-- src/test/java/page/ReadMorePage.java | 8 --- src/test/java/page/RegPage.java | 46 +++++++++++++++ src/test/java/page/ReviewsPage.java | 8 --- src/test/java/page/SideMenuPage.java | 40 ++++++++++--- src/test/java/page/SubMenuPage.java | 8 --- 19 files changed, 406 insertions(+), 66 deletions(-) create mode 100644 src/test/java/FeedbackTest.java create mode 100644 src/test/java/ProductsTest.java create mode 100644 src/test/java/page/BasketPage.java create mode 100644 src/test/java/page/OrderPage.java create mode 100644 src/test/java/page/RegPage.java diff --git a/src/test/java/AccountTest.java b/src/test/java/AccountTest.java index f03da6b..5f414e7 100644 --- a/src/test/java/AccountTest.java +++ b/src/test/java/AccountTest.java @@ -18,7 +18,7 @@ public class AccountTest { public static void setup() { context = new ChromeContext(); context.start(); - context.getDriver().manage().window().setSize(new Dimension(1600, 900)); + context.getDriver().manage().window().setSize(new Dimension(1366, 768)); } @AfterAll diff --git a/src/test/java/FeedbackTest.java b/src/test/java/FeedbackTest.java new file mode 100644 index 0000000..34f07aa --- /dev/null +++ b/src/test/java/FeedbackTest.java @@ -0,0 +1,59 @@ +import context.ChromeContext; +import context.Context; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.support.PageFactory; +import page.*; + +public class FeedbackTest { + private final static String APP_URL_MVideo = "https://www.mvideo.ru/"; + + private static Context context; + + @BeforeAll + public static void setup() { + context = new ChromeContext(); + context.start(); + context.getDriver().manage().window().setSize(new Dimension(1366, 768)); + } + + @AfterAll + public static void quit() { + + context.close(); + } + + @Test + public void testFollow() { + context.getDriver().get(APP_URL_MVideo); + String inputStringMail = "test543321@mail.ru"; + + MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); + pageMain.setEmail(inputStringMail); + pageMain.clickSubmitSub(); + Assertions.assertTrue(pageMain.isFollowSuccess()); + } + + @Test + public void testProductMenu() { + context.getDriver().get(APP_URL_MVideo); + MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); + MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class); + SideMenuPage pageSideMenu = PageFactory.initElements(context.getDriver(), SideMenuPage.class); + ProductPage pageProduct = PageFactory.initElements(context.getDriver(), ProductPage.class); + String eMail = "test543321@mail.ru"; + String text = "тест"; + + pageMain.clickMainMenu(); + pageMainMenu.clickTV(); + pageSideMenu.clickProduct(); + pageProduct.clickProductMenu(); + pageProduct.clickLeaveReviewBtn(); + pageProduct.setReviewData(eMail, text); + Assertions.assertTrue(pageProduct.isProductMenuPresent()); + pageMain.clickLogo(); + } +} diff --git a/src/test/java/FiltersTest.java b/src/test/java/FiltersTest.java index 4988d24..56618e7 100644 --- a/src/test/java/FiltersTest.java +++ b/src/test/java/FiltersTest.java @@ -24,7 +24,7 @@ public class FiltersTest { public static void setup() { context = new ChromeContext(); context.start(); - context.getDriver().manage().window().setSize(new Dimension(1600, 900)); + context.getDriver().manage().window().setSize(new Dimension(1366, 768)); } @AfterAll @@ -131,6 +131,52 @@ public class FiltersTest { pageFilter.clickLogo(); } + @Test + public void testSort() { + context.getDriver().get(APP_URL_MVideo); + + MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); + MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class); + SideMenuPage pageFilter = PageFactory.initElements(context.getDriver(), SideMenuPage.class); + pageMain.clickMainMenu(); + pageMainMenu.clickTV(); + pageFilter.selectAttribute(); + Assertions.assertTrue(pageFilter.isProductContainsPoint()); + pageMain.clickLogo(); + } + + @Test + public void testPrice() { + context.getDriver().get(APP_URL_MVideo); + String minPriceText = "10000"; + String maxPriceText = "50000"; + + MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); + MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class); + SideMenuPage pageFilter = PageFactory.initElements(context.getDriver(), SideMenuPage.class); + pageMain.clickMainMenu(); + pageMainMenu.clickTV(); + pageFilter.setPrice(minPriceText, maxPriceText); + Assertions.assertTrue(pageFilter.isProductContainsPoint()); + pageMain.clickLogo(); + } + + @Test + public void testFavorite() { + context.getDriver().get(APP_URL_MVideo); + MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); + MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class); + SideMenuPage pageSideMenu = PageFactory.initElements(context.getDriver(), SideMenuPage.class); + ProductPage pageProduct = PageFactory.initElements(context.getDriver(), ProductPage.class); + + pageMain.clickMainMenu(); + pageMainMenu.clickTV(); + pageSideMenu.clickProduct(); + pageProduct.clickFavorite(); +// Assertions.assertTrue(pageProduct.isProductMenuPresent()); +// pageMain.clickLogo(); + } + @Test public void testClearCriteria() { context.getDriver().get(APP_URL_MVideo); diff --git a/src/test/java/NavigationTest.java b/src/test/java/NavigationTest.java index 9c28e68..d799a93 100644 --- a/src/test/java/NavigationTest.java +++ b/src/test/java/NavigationTest.java @@ -17,7 +17,7 @@ public class NavigationTest { public static void setup() { context = new ChromeContext(); context.start(); - context.getDriver().manage().window().setSize(new Dimension(1600, 900)); + context.getDriver().manage().window().setSize(new Dimension(1366, 768)); } @AfterAll diff --git a/src/test/java/ProductsTest.java b/src/test/java/ProductsTest.java new file mode 100644 index 0000000..7e9f4fe --- /dev/null +++ b/src/test/java/ProductsTest.java @@ -0,0 +1,71 @@ +import context.ChromeContext; +import context.Context; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.support.PageFactory; +import page.*; + +public class ProductsTest { + private final static String APP_URL_MVideo = "https://www.mvideo.ru/"; + + private static Context context; + + @BeforeAll + public static void setup() { + context = new ChromeContext(); + context.start(); + context.getDriver().manage().window().setSize(new Dimension(1366, 768)); + } + + @AfterAll + public static void quit() { + + context.close(); + } + + @Test + public void testBasketIcon() { + context.getDriver().get(APP_URL_MVideo); + MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); + BasketPage pageBasket = PageFactory.initElements(context.getDriver(), BasketPage.class); + + pageMain.clickBasketIcon(); + Assertions.assertTrue(pageBasket.isBasketPagePresent()); + pageBasket.clickLogo(); + } + + @Test + public void testDeleteFromBaster() { + context.getDriver().get(APP_URL_MVideo); + MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); + BasketPage pageBasket = PageFactory.initElements(context.getDriver(), BasketPage.class); + + pageMain.clickBasketIcon(); + pageBasket.clickDeleteSpan(); + Assertions.assertTrue(pageBasket.isBasketPagePresent()); + pageBasket.clickLogo(); + } + + @Test + public void testOrder() { + context.getDriver().get(APP_URL_MVideo); + MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); + BasketPage pageBasket = PageFactory.initElements(context.getDriver(), BasketPage.class); + AuthPage pageAuth = PageFactory.initElements(context.getDriver(), AuthPage.class); + OrderPage pageOrder = PageFactory.initElements(context.getDriver(), OrderPage.class); + String inputStringMail = "test543321@mail.ru"; + String inputStringPhone = "9603785796"; + String inputStringName = "Антон"; + + pageMain.clickBasketIcon(); + pageBasket.clickOrder(); + pageAuth.clickSubmitBtnAuth(); + pageOrder.setInputStringsAuth(inputStringMail, inputStringPhone, inputStringName); + pageOrder.clickMakeOrderBtn(); + Assertions.assertTrue(pageOrder.isOrderPresent()); + pageOrder.clickLogo(); + } +} diff --git a/src/test/java/context/ChromeContext.java b/src/test/java/context/ChromeContext.java index 05d9cde..1a60718 100644 --- a/src/test/java/context/ChromeContext.java +++ b/src/test/java/context/ChromeContext.java @@ -1,6 +1,7 @@ package context; import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; public class ChromeContext extends Context { private final static String WINDOWS_DRIVER = "chromedriver.exe"; @@ -9,6 +10,8 @@ public class ChromeContext extends Context { @Override protected void createDriver() { +// ChromeOptions options = new ChromeOptions(); +// options.addArguments("--start-maximazed"); driver = new ChromeDriver(); } diff --git a/src/test/java/page/AuthPage.java b/src/test/java/page/AuthPage.java index 53f1478..a21fd47 100644 --- a/src/test/java/page/AuthPage.java +++ b/src/test/java/page/AuthPage.java @@ -1,15 +1,10 @@ package page; -import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.FindBy; -import java.util.List; -import java.util.Set; - public class AuthPage { WebDriver driver; @@ -22,6 +17,9 @@ public class AuthPage { @FindBy(id = "submit-button") private WebElement submitBtn; + @FindBy(xpath = "//*[@id=\"purchaseGuestForm\"]/input[7]") + private WebElement submitBtnAuth; + public AuthPage(WebDriver driver) { this.driver = driver; } @@ -35,4 +33,8 @@ public class AuthPage { public void clickSubmitButton() { submitBtn.sendKeys(Keys.RETURN); } + + public void clickSubmitBtnAuth() { + submitBtnAuth.sendKeys(Keys.RETURN); + } } diff --git a/src/test/java/page/BasketPage.java b/src/test/java/page/BasketPage.java new file mode 100644 index 0000000..59bee85 --- /dev/null +++ b/src/test/java/page/BasketPage.java @@ -0,0 +1,37 @@ +package page; + +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +public class BasketPage { + WebDriver driver; + + public BasketPage(WebDriver driver) { + this.driver = driver; + } + + @FindBy(css = ".c-logo") + private WebElement logoIcon; + + @FindBy(css = ".c-cart-item__delete .c-link") + private WebElement deleteSpan; + + @FindBy(css = ".c-btn_full-size") + private WebElement makeOrderBtn; + + public boolean isBasketPagePresent() { return driver.getTitle().contains("Корзина"); } + + public void clickLogo() { + logoIcon.sendKeys(Keys.RETURN); + } + + public void clickDeleteSpan() { + deleteSpan.sendKeys(Keys.RETURN); + } + + public void clickOrder() { + makeOrderBtn.sendKeys(Keys.RETURN); + } +} diff --git a/src/test/java/page/FacebookPage.java b/src/test/java/page/FacebookPage.java index 248c216..b2c7084 100644 --- a/src/test/java/page/FacebookPage.java +++ b/src/test/java/page/FacebookPage.java @@ -1,14 +1,6 @@ package page; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.FindBy; - -import java.util.List; -import java.util.Set; public class FacebookPage { WebDriver driver; diff --git a/src/test/java/page/FooterMenuPage.java b/src/test/java/page/FooterMenuPage.java index 739cd03..4f1e36e 100644 --- a/src/test/java/page/FooterMenuPage.java +++ b/src/test/java/page/FooterMenuPage.java @@ -1,14 +1,7 @@ package page; import org.openqa.selenium.By; -import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.FindBy; - -import java.util.List; -import java.util.Set; public class FooterMenuPage { WebDriver driver; @@ -17,5 +10,7 @@ public class FooterMenuPage { this.driver = driver; } - public boolean isFooterMenuPresent() { return driver.findElement(By.cssSelector(".lazy-load-image-holder")).isDisplayed(); } + public boolean isFooterMenuPresent() { + return driver.findElement(By.cssSelector(".lazy-load-image-holder")).isDisplayed(); + } } diff --git a/src/test/java/page/MainMenuPage.java b/src/test/java/page/MainMenuPage.java index 5098030..719a05d 100644 --- a/src/test/java/page/MainMenuPage.java +++ b/src/test/java/page/MainMenuPage.java @@ -1,14 +1,11 @@ package page; -import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.FindBy; import java.util.List; -import java.util.Set; public class MainMenuPage { WebDriver driver; diff --git a/src/test/java/page/MainPage.java b/src/test/java/page/MainPage.java index 1a0b53f..6bf5cb4 100644 --- a/src/test/java/page/MainPage.java +++ b/src/test/java/page/MainPage.java @@ -8,7 +8,6 @@ import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.FindBy; import java.util.List; -import java.util.Set; public class MainPage { WebDriver driver; @@ -32,7 +31,7 @@ public class MainPage { private List socialLink; @FindBy(css = ".promo-banner-slider-info .btn") - private List reviews; + private WebElement reviews; @FindBy(css = ".header-search-input") private WebElement inputField; @@ -40,6 +39,14 @@ public class MainPage { @FindBy(css = ".header-login-option-link") private List authReg; + @FindBy(xpath = ".//*[@id=\"js-form-submit-id\"]") + private WebElement basketIcon; + + @FindBy(id = "frm-subscr-email-address") + private WebElement inputEMail; + + @FindBy(id = "submitSubscribe") + private WebElement sbmtSubBtn; public MainPage(WebDriver driver) { this.driver = driver; @@ -47,7 +54,11 @@ public class MainPage { public boolean isLogoPresent() { return driver.findElement(By.cssSelector(".header-logo")).isDisplayed(); } - public boolean isAccountPresent() { return driver.findElement(By.cssSelector(".my-account-personal-photo-placeholder")).isDisplayed(); } + public boolean isAccountPresent() { + return driver.findElement(By.cssSelector(".my-account-personal-photo-placeholder")).isDisplayed(); + } + + public boolean isFollowSuccess() { return driver.findElement(By.cssSelector(".text-success")).isDisplayed(); } public void clickMainMenu() { mainMenu.get(1).sendKeys(Keys.RETURN); @@ -81,7 +92,7 @@ public class MainPage { } public void clickReviews() { - reviews.get(0).sendKeys(Keys.RETURN); + reviews.sendKeys(Keys.RETURN); } public MainPage setSearchString(String text) { @@ -96,4 +107,17 @@ public class MainPage { public void clickAuth() { authReg.get(0).sendKeys(Keys.RETURN); } + + public void clickBasketIcon() { + basketIcon.sendKeys(Keys.RETURN); + } + + public MainPage setEmail(String eMailText) { + inputEMail.sendKeys(eMailText); + return this; + } + + public void clickSubmitSub() { + sbmtSubBtn.sendKeys(Keys.RETURN); + } } diff --git a/src/test/java/page/OrderPage.java b/src/test/java/page/OrderPage.java new file mode 100644 index 0000000..6128572 --- /dev/null +++ b/src/test/java/page/OrderPage.java @@ -0,0 +1,46 @@ +package page; + +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +public class OrderPage { + WebDriver driver; + + @FindBy(id = "field_8") + private WebElement fieldEmailAuth; + + @FindBy(id = "myPhone") + private WebElement fieldPhoneAuth; + + @FindBy(id = "field_6") + private WebElement fieldNameAuth; + + @FindBy(xpath = "/html/body/div[1]/div[2]/div[3]/div[2]/div/form/input[9]") + private WebElement makeOrderBtn; + + @FindBy(css = ".c-logo") + private WebElement logo; + + public OrderPage(WebDriver driver) { + this.driver = driver; + } + + public boolean isOrderPresent() { return driver.getTitle().contains("Информация о заказе"); } + + public OrderPage setInputStringsAuth(String textMail, String textPhone, String textName) { + fieldEmailAuth.sendKeys(textMail); + fieldPhoneAuth.sendKeys(textPhone); + fieldNameAuth.sendKeys(textName); + return this; + } + + public void clickMakeOrderBtn() { + makeOrderBtn.sendKeys(Keys.RETURN); + } + + public void clickLogo() { + logo.sendKeys(Keys.RETURN); + } +} diff --git a/src/test/java/page/ProductPage.java b/src/test/java/page/ProductPage.java index cca6125..4f57781 100644 --- a/src/test/java/page/ProductPage.java +++ b/src/test/java/page/ProductPage.java @@ -4,11 +4,9 @@ import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.FindBy; import java.util.List; -import java.util.Set; public class ProductPage { WebDriver driver; @@ -16,15 +14,37 @@ public class ProductPage { @FindBy(css = ".c-tabs__menu .c-tabs__menu-link") private List productMenu; + @FindBy(css = ".c-checkbox__icon") + private WebElement favoriteSpan; + + @FindBy(css = ".product-leave-review-btn") + private WebElement leaveReviewBtn; + + @FindBy(id = "userEmail") + private WebElement inputUserName; + + @FindBy(id = "userComment") + private WebElement inputReviewText; + public ProductPage(WebDriver driver) { this.driver = driver; } - public boolean isProductMenuPresent() { return driver.getTitle().contains("характеристики, техническое описание"); } + public boolean isProductMenuPresent() { return driver.getTitle().contains("отзывы"); } public boolean isProductPresent() { return driver.findElement(By.cssSelector(".product-tile")).isDisplayed(); } public void clickProductMenu() { - productMenu.get(1).sendKeys(Keys.RETURN); + productMenu.get(2).sendKeys(Keys.RETURN); + } + + public void clickFavorite() { favoriteSpan.sendKeys(Keys.RETURN); } + + public void clickLeaveReviewBtn() { leaveReviewBtn.sendKeys(Keys.RETURN); } + + public ProductPage setReviewData(String eMailText, String reviewText) { + inputUserName.sendKeys(eMailText); + inputReviewText.sendKeys(reviewText); + return this; } } diff --git a/src/test/java/page/ReadMorePage.java b/src/test/java/page/ReadMorePage.java index f499d78..5392a66 100644 --- a/src/test/java/page/ReadMorePage.java +++ b/src/test/java/page/ReadMorePage.java @@ -1,14 +1,6 @@ package page; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.FindBy; - -import java.util.List; -import java.util.Set; public class ReadMorePage { WebDriver driver; diff --git a/src/test/java/page/RegPage.java b/src/test/java/page/RegPage.java new file mode 100644 index 0000000..b90845d --- /dev/null +++ b/src/test/java/page/RegPage.java @@ -0,0 +1,46 @@ +package page; + +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +public class RegPage { + WebDriver driver; + + @FindBy(id = "register-form-name-input") + private WebElement inputName; + + @FindBy(id = "register-form-phone") + private WebElement inputPhone; + + @FindBy(id = "register-register-form-email-phone") + private WebElement inputEmail; + + @FindBy(id = "register-form-password") + private WebElement inputPass; + + @FindBy(id = "register-form-confirm-password") + private WebElement inputPassConfirm; + + @FindBy(css = ".add-address-submit-btn") + private WebElement submitBtn; + + public RegPage(WebDriver driver) { + this.driver = driver; + } + + public RegPage setInputStrings(String textName, String textPhone, String textEmail, String textPass, + String textPassConfirm) { + inputName.sendKeys(textName); + inputPhone.sendKeys(textPhone); + inputEmail.sendKeys(textEmail); + inputPass.sendKeys(textPass); + inputPassConfirm.sendKeys(textPassConfirm); + return this; + } + + public void clickSubmitBtn() { + submitBtn.sendKeys(Keys.RETURN); + } +} diff --git a/src/test/java/page/ReviewsPage.java b/src/test/java/page/ReviewsPage.java index 0027e7e..83ca062 100644 --- a/src/test/java/page/ReviewsPage.java +++ b/src/test/java/page/ReviewsPage.java @@ -1,14 +1,6 @@ package page; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.FindBy; - -import java.util.List; -import java.util.Set; public class ReviewsPage { WebDriver driver; diff --git a/src/test/java/page/SideMenuPage.java b/src/test/java/page/SideMenuPage.java index 1f10084..b6c94c3 100644 --- a/src/test/java/page/SideMenuPage.java +++ b/src/test/java/page/SideMenuPage.java @@ -4,12 +4,9 @@ import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.FindBy; -import javax.annotation.CheckForNull; import java.util.List; -import java.util.Set; public class SideMenuPage { WebDriver driver; @@ -26,13 +23,29 @@ public class SideMenuPage { @FindBy(css = ".c-plp-facets__clear-wrapper .c-btn") private WebElement clearBtn; + @FindBy(css = ".o-plp-container_sub-header .select-button") + private WebElement selectBtn; + + @FindBy(css = ".drop-box a") + private List attribute; + + @FindBy(css = ".c-text-field .facet-price-min") + private WebElement priceLeft; + + @FindBy(css = ".c-text-field .facet-price-max") + private WebElement priceRight; + public SideMenuPage(WebDriver driver) { this.driver = driver; } - public boolean isSideBarPresent() { return driver.findElement(By.cssSelector(".c-plp-facets__item-link")).isDisplayed(); } + public boolean isSideBarPresent() { + return driver.findElement(By.cssSelector(".c-plp-facets__item-link")).isDisplayed(); + } - public boolean isProductContainsPoint() { return driver.findElement(By.cssSelector(".c-product-tile__description")).isDisplayed(); } + public boolean isProductContainsPoint() { + return driver.findElement(By.cssSelector(".c-product-tile__description")).isDisplayed(); + } public void clickProduct() { product.get(0).sendKeys(Keys.RETURN); @@ -50,7 +63,20 @@ public class SideMenuPage { } } - public void clickClearBtn() { - clearBtn.sendKeys(Keys.RETURN); + public void clickClearBtn() { clearBtn.sendKeys(Keys.RETURN); } + + public void selectAttribute() { + selectBtn.sendKeys(Keys.RETURN); + attribute.get(3).sendKeys(Keys.RETURN); + } + + public SideMenuPage setPrice(String minPrice, String maxPrice) { + priceLeft.clear(); + priceLeft.sendKeys(minPrice); + priceRight.sendKeys(Keys.RETURN); + priceRight.clear(); + priceRight.sendKeys(maxPrice); + priceRight.sendKeys(Keys.RETURN); + return this; } } diff --git a/src/test/java/page/SubMenuPage.java b/src/test/java/page/SubMenuPage.java index a625f64..972a608 100644 --- a/src/test/java/page/SubMenuPage.java +++ b/src/test/java/page/SubMenuPage.java @@ -1,14 +1,6 @@ package page; -import org.openqa.selenium.By; -import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; -import org.openqa.selenium.support.FindBy; - -import java.util.List; -import java.util.Set; public class SubMenuPage { WebDriver driver;