From 4d31ca6f2bb2e975d4ad00b1020d2f10aaa3b214 Mon Sep 17 00:00:00 2001 From: mrHewd Date: Sat, 28 Apr 2018 12:00:44 +0300 Subject: [PATCH] Edited tests --- src/test/java/AccountTest.java | 1 - src/test/java/FeedbackTest.java | 8 ++- src/test/java/FiltersTest.java | 79 +++++++++++++++------------- src/test/java/NavigationTest.java | 9 ---- src/test/java/ProductsTest.java | 4 -- src/test/java/page/MainPage.java | 6 ++- src/test/java/page/ProductPage.java | 13 ++++- src/test/java/page/SideMenuPage.java | 20 +++++-- 8 files changed, 80 insertions(+), 60 deletions(-) diff --git a/src/test/java/AccountTest.java b/src/test/java/AccountTest.java index 5f414e7..2e83972 100644 --- a/src/test/java/AccountTest.java +++ b/src/test/java/AccountTest.java @@ -23,7 +23,6 @@ public class AccountTest { @AfterAll public static void quit() { - context.close(); } diff --git a/src/test/java/FeedbackTest.java b/src/test/java/FeedbackTest.java index 34f07aa..3940ab6 100644 --- a/src/test/java/FeedbackTest.java +++ b/src/test/java/FeedbackTest.java @@ -22,23 +22,22 @@ public class FeedbackTest { @AfterAll public static void quit() { - context.close(); } @Test - public void testFollow() { + public void testSubscribe() { 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()); + Assertions.assertTrue(pageMain.isSubSuccess()); } @Test - public void testProductMenu() { + public void testLeaveReview() { context.getDriver().get(APP_URL_MVideo); MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class); @@ -54,6 +53,5 @@ public class FeedbackTest { 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 56618e7..1cb4954 100644 --- a/src/test/java/FiltersTest.java +++ b/src/test/java/FiltersTest.java @@ -29,40 +29,40 @@ public class FiltersTest { @AfterAll public static void quit() { - context.close(); } @Test public void testSearch() { context.getDriver().get(APP_URL_MVideo); - String searchString = "телевизор samsung"; + String searchString = "Телевизор Samsung"; MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); ProductPage pageProduct = PageFactory.initElements(context.getDriver(), ProductPage.class); pageMain.setSearchString(searchString); pageMain.clickSubmitButton(); - Assertions.assertTrue(pageProduct.isProductPresent()); - pageMain.clickLogo(); + Assertions.assertTrue(pageProduct.isProductCorrect(searchString)); } @Test public void testProductOneCategoryOnePoint() { context.getDriver().get(APP_URL_MVideo); + int point = 1; 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.clickPoint(5); + pageFilter.clickCategoryPoint(point); Assertions.assertTrue(pageFilter.isProductContainsPoint()); - pageFilter.clickLogo(); } @Test public void testProductOneCategoryTwoPoints() { context.getDriver().get(APP_URL_MVideo); + int firstCategoryPoint = 1; + int secondCategoryPoint = 2; MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class); @@ -70,33 +70,35 @@ public class FiltersTest { pageMain.clickMainMenu(); pageMainMenu.clickTV(); point.clear(); - point.add(5); - point.add(6); - pageFilter.clickPoints(point); + point.add(firstCategoryPoint); + point.add(secondCategoryPoint); + pageFilter.clickCategoryTwoPoints(point); Assertions.assertTrue(pageFilter.isProductContainsPoint()); - pageFilter.clickLogo(); } @Test public void testProductTwoCategoryOnePoint() { context.getDriver().get(APP_URL_MVideo); + int categoryPoint = 1; + int brandPoint = 2; 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(); - point.clear(); - point.add(3); - point.add(6); - pageFilter.clickPoints(point); + pageFilter.clickCategoryPoint(categoryPoint); + pageFilter.clickBrandPoint(brandPoint); Assertions.assertTrue(pageFilter.isProductContainsPoint()); - pageFilter.clickLogo(); } @Test public void testProductTwoCategoryTwoPoints() { context.getDriver().get(APP_URL_MVideo); + int firstCategoryPoint = 1; + int secondCategoryPoint = 2; + int firstBrandPoint = 2; + int secondBrandPoint = 4; MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class); @@ -104,31 +106,34 @@ public class FiltersTest { pageMain.clickMainMenu(); pageMainMenu.clickTV(); point.clear(); - point.add(3); - point.add(4); - point.add(6); - point.add(7); - pageFilter.clickPoints(point); + point.add(firstCategoryPoint); + point.add(secondCategoryPoint); + pageFilter.clickCategoryTwoPoints(point); + point.clear(); + point.add(firstBrandPoint); + point.add(secondBrandPoint); + pageFilter.clickBrandTwoPoints(point); Assertions.assertTrue(pageFilter.isProductContainsPoint()); - pageFilter.clickLogo(); } @Test public void testProductCombine() { context.getDriver().get(APP_URL_MVideo); + int categoryPoint = 1; + int firstBrandPoint = 1; + int secondBrandPoint = 3; 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.clickCategoryPoint(categoryPoint); point.clear(); - point.add(3); - point.add(6); - point.add(4); - pageFilter.clickPoints(point); + point.add(firstBrandPoint); + point.add(secondBrandPoint); + pageFilter.clickBrandTwoPoints(point); Assertions.assertTrue(pageFilter.isProductContainsPoint()); - pageFilter.clickLogo(); } @Test @@ -142,7 +147,6 @@ public class FiltersTest { pageMainMenu.clickTV(); pageFilter.selectAttribute(); Assertions.assertTrue(pageFilter.isProductContainsPoint()); - pageMain.clickLogo(); } @Test @@ -158,7 +162,6 @@ public class FiltersTest { pageMainMenu.clickTV(); pageFilter.setPrice(minPriceText, maxPriceText); Assertions.assertTrue(pageFilter.isProductContainsPoint()); - pageMain.clickLogo(); } @Test @@ -173,13 +176,16 @@ public class FiltersTest { pageMainMenu.clickTV(); pageSideMenu.clickProduct(); pageProduct.clickFavorite(); -// Assertions.assertTrue(pageProduct.isProductMenuPresent()); -// pageMain.clickLogo(); + Assertions.assertTrue(pageProduct.isProductMenuPresent()); } @Test public void testClearCriteria() { context.getDriver().get(APP_URL_MVideo); + int firstCategoryPoint = 1; + int secondCategoryPoint = 2; + int firstBrandPoint = 2; + int secondBrandPoint = 4; MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class); @@ -187,13 +193,14 @@ public class FiltersTest { pageMain.clickMainMenu(); pageMainMenu.clickTV(); point.clear(); - point.add(3); - point.add(4); - point.add(6); - point.add(7); - pageFilter.clickPoints(point); + point.add(firstCategoryPoint); + point.add(secondCategoryPoint); + pageFilter.clickCategoryTwoPoints(point); + point.clear(); + point.add(firstBrandPoint); + point.add(secondBrandPoint); + pageFilter.clickBrandTwoPoints(point); pageFilter.clickClearBtn(); Assertions.assertTrue(pageFilter.isProductContainsPoint()); - pageFilter.clickLogo(); } } diff --git a/src/test/java/NavigationTest.java b/src/test/java/NavigationTest.java index d799a93..3b573e3 100644 --- a/src/test/java/NavigationTest.java +++ b/src/test/java/NavigationTest.java @@ -22,7 +22,6 @@ public class NavigationTest { @AfterAll public static void quit() { - context.close(); } @@ -43,7 +42,6 @@ public class NavigationTest { pageMain.clickMainMenu(); Assertions.assertTrue(pageMainMenu.isMainMenuPresent()); - pageMain.clickLogo(); } @Test @@ -54,7 +52,6 @@ public class NavigationTest { pageMain.clickSubMenu(); Assertions.assertTrue(pageSubMenu.isSubMenuPresent()); - pageMain.clickLogo(); } @Test @@ -65,7 +62,6 @@ public class NavigationTest { pageMain.clickFooterMenu(); Assertions.assertTrue(pageFooter.isFooterMenuPresent()); - pageMain.clickLogo(); } @Test @@ -76,7 +72,6 @@ public class NavigationTest { pageMain.clickReadMore(); Assertions.assertTrue(pageReadMore.isReadMorePresent()); - pageMain.clickLogo(); } @Test @@ -85,7 +80,6 @@ public class NavigationTest { MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); pageMain.clickSocialLink(); - pageMain.clickLogo(); } @Test @@ -96,7 +90,6 @@ public class NavigationTest { pageMain.clickReviews(); Assertions.assertTrue(pageReviews.areReviewsPresent()); - pageMain.clickLogo(); } @Test @@ -109,7 +102,6 @@ public class NavigationTest { pageMain.clickMainMenu(); pageMainMenu.clickTV(); Assertions.assertTrue(pageSideBar.isSideBarPresent()); - pageMain.clickLogo(); } @Test @@ -125,6 +117,5 @@ public class NavigationTest { pageSideMenu.clickProduct(); pageProduct.clickProductMenu(); Assertions.assertTrue(pageProduct.isProductMenuPresent()); - pageMain.clickLogo(); } } diff --git a/src/test/java/ProductsTest.java b/src/test/java/ProductsTest.java index 7e9f4fe..b783465 100644 --- a/src/test/java/ProductsTest.java +++ b/src/test/java/ProductsTest.java @@ -22,7 +22,6 @@ public class ProductsTest { @AfterAll public static void quit() { - context.close(); } @@ -34,7 +33,6 @@ public class ProductsTest { pageMain.clickBasketIcon(); Assertions.assertTrue(pageBasket.isBasketPagePresent()); - pageBasket.clickLogo(); } @Test @@ -46,7 +44,6 @@ public class ProductsTest { pageMain.clickBasketIcon(); pageBasket.clickDeleteSpan(); Assertions.assertTrue(pageBasket.isBasketPagePresent()); - pageBasket.clickLogo(); } @Test @@ -66,6 +63,5 @@ public class ProductsTest { pageOrder.setInputStringsAuth(inputStringMail, inputStringPhone, inputStringName); pageOrder.clickMakeOrderBtn(); Assertions.assertTrue(pageOrder.isOrderPresent()); - pageOrder.clickLogo(); } } diff --git a/src/test/java/page/MainPage.java b/src/test/java/page/MainPage.java index 6bf5cb4..b68a857 100644 --- a/src/test/java/page/MainPage.java +++ b/src/test/java/page/MainPage.java @@ -58,7 +58,7 @@ public class MainPage { return driver.findElement(By.cssSelector(".my-account-personal-photo-placeholder")).isDisplayed(); } - public boolean isFollowSuccess() { return driver.findElement(By.cssSelector(".text-success")).isDisplayed(); } + public boolean isSubSuccess() { return driver.findElement(By.cssSelector(".text-success")).isDisplayed(); } public void clickMainMenu() { mainMenu.get(1).sendKeys(Keys.RETURN); @@ -108,6 +108,10 @@ public class MainPage { authReg.get(0).sendKeys(Keys.RETURN); } + public void clickReg() { + authReg.get(1).sendKeys(Keys.RETURN); + } + public void clickBasketIcon() { basketIcon.sendKeys(Keys.RETURN); } diff --git a/src/test/java/page/ProductPage.java b/src/test/java/page/ProductPage.java index 4f57781..fc5affc 100644 --- a/src/test/java/page/ProductPage.java +++ b/src/test/java/page/ProductPage.java @@ -26,13 +26,24 @@ public class ProductPage { @FindBy(id = "userComment") private WebElement inputReviewText; + @FindBy(css = ".text-cutter-wrapper") + private List titles; + public ProductPage(WebDriver driver) { this.driver = driver; } public boolean isProductMenuPresent() { return driver.getTitle().contains("отзывы"); } - public boolean isProductPresent() { return driver.findElement(By.cssSelector(".product-tile")).isDisplayed(); } + public boolean isProductCorrect(String searchString) { + boolean correct = true; + for (int i = 0; i < titles.size(); i++) { + if (!titles.get(i).getText().contains(searchString)) { + correct = false; + } + } + return correct; + } public void clickProductMenu() { productMenu.get(2).sendKeys(Keys.RETURN); diff --git a/src/test/java/page/SideMenuPage.java b/src/test/java/page/SideMenuPage.java index b6c94c3..88431dd 100644 --- a/src/test/java/page/SideMenuPage.java +++ b/src/test/java/page/SideMenuPage.java @@ -20,6 +20,12 @@ public class SideMenuPage { @FindBy(css = ".c-plp-facets__item-link") private List points; + @FindBy(css = "#category-section .c-plp-facets__item-link") + private List categoryPoints; + + @FindBy(css = "#brand-section .c-plp-facets__item-link") + private List brandPoints; + @FindBy(css = ".c-plp-facets__clear-wrapper .c-btn") private WebElement clearBtn; @@ -55,11 +61,19 @@ public class SideMenuPage { mVideoLogo.sendKeys(Keys.RETURN); } - public void clickPoint(int point) { points.get(point).sendKeys(Keys.RETURN); } + public void clickCategoryPoint(int point) { categoryPoints.get(point).sendKeys(Keys.RETURN); } - public void clickPoints(List point) { + public void clickBrandPoint(int point) { brandPoints.get(point).sendKeys(Keys.RETURN); } + + public void clickCategoryTwoPoints(List point) { for (int i = 0; i < point.size(); i++) { - points.get(point.get(i)).sendKeys(Keys.RETURN); + categoryPoints.get(point.get(i)).sendKeys(Keys.RETURN); + } + } + + public void clickBrandTwoPoints(List point) { + for (int i = 0; i < point.size(); i++) { + brandPoints.get(point.get(i)).sendKeys(Keys.RETURN); } }