From 594b41c40213ace317d4aa6b789b85cd59d61649 Mon Sep 17 00:00:00 2001 From: StroevaJ Date: Fri, 11 May 2018 22:52:22 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=B7=D0=B0=D0=BC=D0=B5=D1=87=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Stroeva/src/test/java/FilterTests.java | 2 +- Stroeva/src/test/java/NavigationTests.java | 15 +++++++++----- Stroeva/src/test/java/page/MainPage.java | 20 +++++++++++++++++++ Stroeva/src/test/java/page/NavFilterPage.java | 12 +++++++---- Stroeva/src/test/java/page/SearchPage.java | 6 +++--- 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/Stroeva/src/test/java/FilterTests.java b/Stroeva/src/test/java/FilterTests.java index 30a0642..77eadb7 100644 --- a/Stroeva/src/test/java/FilterTests.java +++ b/Stroeva/src/test/java/FilterTests.java @@ -34,7 +34,7 @@ public class FilterTests { page.insertSearchText("Древние"); page.insertEnterSearchText(); SearchPage pageAn = PageFactory.initElements(context.getDriver(), SearchPage.class); - Assertions.assertTrue(pageAn.isSearchPresent()); + Assertions.assertTrue(pageAn.isSearchPresent("Древние")); } @Test diff --git a/Stroeva/src/test/java/NavigationTests.java b/Stroeva/src/test/java/NavigationTests.java index 077490a..a491f24 100644 --- a/Stroeva/src/test/java/NavigationTests.java +++ b/Stroeva/src/test/java/NavigationTests.java @@ -46,44 +46,49 @@ public class NavigationTests { public void testRating() { context.getDriver().get(APP_URL); MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class); + String str = page.getRating(); page.clickRating(); NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class); - Assertions.assertTrue(pageAn.isContentPresent()); + Assertions.assertTrue(pageAn.isContentPresent(str)); } @Test public void testYear() { context.getDriver().get(APP_URL); MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class); + String str = page.getYear(); page.clickYear(); NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class); - Assertions.assertTrue(pageAn.isContentPresent()); + Assertions.assertTrue(pageAn.isContentPresent(str)); } @Test public void testCountry() { context.getDriver().get(APP_URL); MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class); + String str = page.getCountry(); page.clickCountry(); NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class); - Assertions.assertTrue(pageAn.isContentPresent()); + Assertions.assertTrue(pageAn.isContentPresent(str)); } @Test public void testGenre() { context.getDriver().get(APP_URL); MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class); + String str = page.getGenre(); page.clickGenre(); NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class); - Assertions.assertTrue(pageAn.isContentPresent()); + Assertions.assertTrue(pageAn.isContentPresent(str)); } @Test public void testMenu() { context.getDriver().get(APP_URL); MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class); + String str = page.getElementMenu(); page.clickMenu(); NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class); - Assertions.assertTrue(pageAn.isContentPresent()); + Assertions.assertTrue(pageAn.isPagePresent(str)); } } diff --git a/Stroeva/src/test/java/page/MainPage.java b/Stroeva/src/test/java/page/MainPage.java index e8fe5d2..9247957 100644 --- a/Stroeva/src/test/java/page/MainPage.java +++ b/Stroeva/src/test/java/page/MainPage.java @@ -71,6 +71,26 @@ public class MainPage { menuElement.click(); } + public String getRating(){ + return ratingElement.getText(); + } + + public String getYear(){ + return yearElement.getText(); + } + + public String getCountry(){ + return countryElement.getText(); + } + + public String getGenre(){ + return genreElement.getText(); + } + + public String getElementMenu(){ + return menuElement.getText(); + } + public boolean isFilterPresent() { return filterElement.isDisplayed(); } diff --git a/Stroeva/src/test/java/page/NavFilterPage.java b/Stroeva/src/test/java/page/NavFilterPage.java index fb7b707..962697e 100644 --- a/Stroeva/src/test/java/page/NavFilterPage.java +++ b/Stroeva/src/test/java/page/NavFilterPage.java @@ -7,14 +7,18 @@ import org.openqa.selenium.support.FindBy; public class NavFilterPage { WebDriver driver; - @FindBy(id = "dle-content") - private WebElement contentElement; + @FindBy(xpath = "/html/body/div[1]/div[2]/div[2]/h1") + private WebElement title; public NavFilterPage(WebDriver driver) { this.driver = driver; } - public boolean isContentPresent() { - return contentElement.isDisplayed(); + public boolean isPagePresent(String str) { + return driver.getTitle().toUpperCase().contains(str.toUpperCase()); + } + + public boolean isContentPresent(String str) { + return title.getText().toUpperCase().contains(str.toUpperCase()); } } diff --git a/Stroeva/src/test/java/page/SearchPage.java b/Stroeva/src/test/java/page/SearchPage.java index b8ac6d7..4e1535d 100644 --- a/Stroeva/src/test/java/page/SearchPage.java +++ b/Stroeva/src/test/java/page/SearchPage.java @@ -7,14 +7,14 @@ import org.openqa.selenium.support.FindBy; public class SearchPage { WebDriver driver; - @FindBy(css = ".res-search") + @FindBy(xpath = "//*[@id=\"serials\"]/div/div[2]/div[1]") private WebElement searchElement; public SearchPage(WebDriver driver) { this.driver = driver; } - public boolean isSearchPresent() { - return searchElement.isDisplayed(); + public boolean isSearchPresent(String str) { + return searchElement.getText().contains(str); } }