diff --git a/Skalkin/src/test/java/SearchTests.java b/Skalkin/src/test/java/SearchTests.java index f9e1716..3da5703 100644 --- a/Skalkin/src/test/java/SearchTests.java +++ b/Skalkin/src/test/java/SearchTests.java @@ -24,7 +24,7 @@ public class SearchTests { @AfterAll public static void quit() { - context.close(); + //context.close(); } @Test @@ -36,7 +36,7 @@ public class SearchTests { page.enterSearch(); SearchExtendedResultPage pageTo = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageTo.isResultTopElementPresent()); + Assertions.assertTrue(pageTo.isFirstResultElementPresent()); } @Test @@ -50,7 +50,7 @@ public class SearchTests { page.enterSearch(); SearchExtendedResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageResult.isResultTopElementPresent()); + Assertions.assertTrue(pageResult.isFirstResultElementPresent()); } @Test @@ -59,14 +59,14 @@ public class SearchTests { SearchByCreatorsPage page = PageFactory.initElements(context.getDriver(), SearchByCreatorsPage.class);//Выбрать пункт меню page.insertNameSearch("Безруков"); - Thread.sleep(2000); + Thread.sleep(2500); page.clickDown(); page.clickEnter(); - Thread.sleep(500); + Thread.sleep(1000); page.enterSearch(); SearchByCreatorsResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchByCreatorsResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageResult.isResultCreatorsPresent()); + Assertions.assertTrue(pageResult.isFirstResultCreatorsPresent()); } @Test @@ -78,7 +78,7 @@ public class SearchTests { page.enterSearch(); SearchExtendedResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageResult.isResultTopElementPresent()); + Assertions.assertTrue(pageResult.isActorResultElementPresent()); } @Test @@ -90,7 +90,8 @@ public class SearchTests { page.enterSearch(); SearchInTextResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchInTextResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageResult.isHeaderElementPresent()); + String str = pageResult.getNewsElementToString(); + Assertions.assertTrue(pageResult.getNewsElementToString().contains("Веном")); } @Test @@ -102,7 +103,7 @@ public class SearchTests { page.enterSearch(); SearchExtendedResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageResult.isResultTopElementPresent()); + Assertions.assertTrue(pageResult.isUsersResultElementPresent("Антон")); } @Test @@ -114,33 +115,38 @@ public class SearchTests { page.enterSearch(); SearchByKeywordResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchByKeywordResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageResult.isNewsElementPresent()); + Assertions.assertTrue(pageResult.isFirstResultElementPresent("Война")); } @Test - public void testSearchMovieByWord(){ + public void testSearchMovieByWord() throws InterruptedException { context.getDriver().get(APP_URL_SEARCH);//Открыта любая страница сайта, кроме специальных SearchMovieByWordPage page = PageFactory.initElements(context.getDriver(), SearchMovieByWordPage.class);//Выбрать пункт меню page.insertNameSearch("Магия"); + Thread.sleep(500); page.clickDown(); + Thread.sleep(500); page.clickDown(); + Thread.sleep(500); page.clickEnter(); + Thread.sleep(1000); page.enterSearch(); SearchByCreatorsResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchByCreatorsResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageResult.isResultCreatorsPresent()); + Assertions.assertTrue(pageResult.isFirstResultByWordPresent()); } @Test - public void testSearchByStudio() { + public void testSearchByStudio() throws InterruptedException { context.getDriver().get(APP_URL_SEARCH);//Открыта любая страница сайта, кроме специальных SearchByStudioPage page = PageFactory.initElements(context.getDriver(), SearchByStudioPage.class);//Выбрать пункт меню page.insertNameSearch("Disney"); + Thread.sleep(1000); page.enterSearch(); SearchByKeywordResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchByKeywordResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageResult.isNewsElementPresent()); + Assertions.assertTrue(pageResult.isFirstResultElementPresent("Disney")); } } diff --git a/Skalkin/src/test/java/page/search/SearchByCreatorsResultPage.java b/Skalkin/src/test/java/page/search/SearchByCreatorsResultPage.java index 45673b9..0dd583d 100644 --- a/Skalkin/src/test/java/page/search/SearchByCreatorsResultPage.java +++ b/Skalkin/src/test/java/page/search/SearchByCreatorsResultPage.java @@ -10,10 +10,24 @@ public class SearchByCreatorsResultPage { @FindBy(css = ".search_adv") private WebElement resultCreatorsElement; + @FindBy(xpath = "//a[@href='/film/brigada-2002-77039/sr/1/']") + private WebElement firstResultCreatorsElement; + + @FindBy(xpath = "//a[@href='/film/garri-potter-i-filosofskiy-kamen-2001-689/sr/1/']") + private WebElement firstResultByWordElement; + public SearchByCreatorsResultPage(WebDriver driver) { this.driver = driver; } + public boolean isFirstResultByWordPresent() { + return firstResultByWordElement.isDisplayed(); + } + + public boolean isFirstResultCreatorsPresent() { + return firstResultCreatorsElement.isDisplayed(); + } + public boolean isResultCreatorsPresent() { return resultCreatorsElement.isDisplayed(); } diff --git a/Skalkin/src/test/java/page/search/SearchByKeywordResultPage.java b/Skalkin/src/test/java/page/search/SearchByKeywordResultPage.java index cf36725..e2c6a16 100644 --- a/Skalkin/src/test/java/page/search/SearchByKeywordResultPage.java +++ b/Skalkin/src/test/java/page/search/SearchByKeywordResultPage.java @@ -10,10 +10,17 @@ public class SearchByKeywordResultPage { @FindBy(css = ".news") private WebElement newsElement; + @FindBy(css = ".all") + private WebElement firstResultElement; + public SearchByKeywordResultPage(WebDriver driver) { this.driver = driver; } + public boolean isFirstResultElementPresent(String str) { + return firstResultElement.getText().toLowerCase().contains(str.toLowerCase()); + } + public boolean isNewsElementPresent() { return newsElement.isDisplayed(); } diff --git a/Skalkin/src/test/java/page/search/SearchExtendedResultPage.java b/Skalkin/src/test/java/page/search/SearchExtendedResultPage.java index abbb953..f2d4feb 100644 --- a/Skalkin/src/test/java/page/search/SearchExtendedResultPage.java +++ b/Skalkin/src/test/java/page/search/SearchExtendedResultPage.java @@ -10,10 +10,31 @@ public class SearchExtendedResultPage { @FindBy(css = ".search_results_top") private WebElement resultTopElement; + @FindBy(xpath = "//a[@href='/film/koma-2018-933208/sr/1/']") + private WebElement firstResultElement; + + @FindBy(xpath = "//a[@href='/name/224620/sr/1/']") + private WebElement actorResultElement; + + @FindBy(css = ".gray") + private WebElement usersResultElement; + public SearchExtendedResultPage(WebDriver driver) { this.driver = driver; } + public boolean isUsersResultElementPresent(String str) { + return usersResultElement.getText().contains(str); + } + + public boolean isActorResultElementPresent() { + return actorResultElement.isDisplayed(); + } + + public boolean isFirstResultElementPresent() { + return firstResultElement.isDisplayed(); + } + public boolean isResultTopElementPresent() { return resultTopElement.isDisplayed(); } diff --git a/Skalkin/src/test/java/page/search/SearchInTextResultPage.java b/Skalkin/src/test/java/page/search/SearchInTextResultPage.java index e90bb64..9cb242f 100644 --- a/Skalkin/src/test/java/page/search/SearchInTextResultPage.java +++ b/Skalkin/src/test/java/page/search/SearchInTextResultPage.java @@ -10,10 +10,18 @@ public class SearchInTextResultPage { @FindBy(css = ".textorangebig") private WebElement headerElement; + @FindBy(css = ".news") + private WebElement newsElement; + + public SearchInTextResultPage(WebDriver driver) { this.driver = driver; } + public String getNewsElementToString(){ + return newsElement.getText(); + } + public boolean isHeaderElementPresent() { return headerElement.isDisplayed(); }