From 76e1d98652e6e70602bfd2ad408ceed097d0ad13 Mon Sep 17 00:00:00 2001 From: Anton Skalkin Date: Sun, 13 May 2018 18:28:40 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D1=82=D0=B5=D1=81=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0.=20?= =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D1=8F=D0=B5=D1=82=20=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D1=8B=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D0=B5.=20=D0=92=D0=B5=D1=80=D1=81=D0=B8?= =?UTF-8?q?=D1=8F=202.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Skalkin/src/test/java/SearchTests.java | 11 ++++--- .../search/SearchByCreatorsResultPage.java | 6 ++-- .../search/SearchByKeywordResultPage.java | 19 ++++++++--- .../page/search/SearchExtendedResultPage.java | 32 +++++++++++++------ .../page/search/SearchInTextResultPage.java | 19 +++++++++-- 5 files changed, 62 insertions(+), 25 deletions(-) diff --git a/Skalkin/src/test/java/SearchTests.java b/Skalkin/src/test/java/SearchTests.java index 3da5703..bfd291e 100644 --- a/Skalkin/src/test/java/SearchTests.java +++ b/Skalkin/src/test/java/SearchTests.java @@ -36,7 +36,7 @@ public class SearchTests { page.enterSearch(); SearchExtendedResultPage pageTo = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageTo.isFirstResultElementPresent()); + Assertions.assertTrue(pageTo.isKomaFromResultElementPresent()); } @Test @@ -50,7 +50,7 @@ public class SearchTests { page.enterSearch(); SearchExtendedResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageResult.isFirstResultElementPresent()); + Assertions.assertTrue(pageResult.isKomaFromResultElementPresent()); } @Test @@ -66,7 +66,7 @@ public class SearchTests { page.enterSearch(); SearchByCreatorsResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchByCreatorsResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageResult.isFirstResultCreatorsPresent()); + Assertions.assertTrue(pageResult.isBrigadaFromResultCreatorsPresent()); } @Test @@ -78,7 +78,7 @@ public class SearchTests { page.enterSearch(); SearchExtendedResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница - Assertions.assertTrue(pageResult.isActorResultElementPresent()); + Assertions.assertTrue(pageResult.isBezrukovFromResultElementPresent()); } @Test @@ -91,7 +91,8 @@ public class SearchTests { SearchInTextResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchInTextResultPage.class);//Корректно отображена выбранная страница String str = pageResult.getNewsElementToString(); - Assertions.assertTrue(pageResult.getNewsElementToString().contains("Веном")); + + Assertions.assertTrue(pageResult.isListElementPresent("Веном")); } @Test diff --git a/Skalkin/src/test/java/page/search/SearchByCreatorsResultPage.java b/Skalkin/src/test/java/page/search/SearchByCreatorsResultPage.java index 0dd583d..c5a09c6 100644 --- a/Skalkin/src/test/java/page/search/SearchByCreatorsResultPage.java +++ b/Skalkin/src/test/java/page/search/SearchByCreatorsResultPage.java @@ -11,7 +11,7 @@ public class SearchByCreatorsResultPage { private WebElement resultCreatorsElement; @FindBy(xpath = "//a[@href='/film/brigada-2002-77039/sr/1/']") - private WebElement firstResultCreatorsElement; + private WebElement brigadaFromResultCreatorsElement; @FindBy(xpath = "//a[@href='/film/garri-potter-i-filosofskiy-kamen-2001-689/sr/1/']") private WebElement firstResultByWordElement; @@ -24,8 +24,8 @@ public class SearchByCreatorsResultPage { return firstResultByWordElement.isDisplayed(); } - public boolean isFirstResultCreatorsPresent() { - return firstResultCreatorsElement.isDisplayed(); + public boolean isBrigadaFromResultCreatorsPresent() { + return brigadaFromResultCreatorsElement.isDisplayed(); } public boolean isResultCreatorsPresent() { diff --git a/Skalkin/src/test/java/page/search/SearchByKeywordResultPage.java b/Skalkin/src/test/java/page/search/SearchByKeywordResultPage.java index e2c6a16..672e425 100644 --- a/Skalkin/src/test/java/page/search/SearchByKeywordResultPage.java +++ b/Skalkin/src/test/java/page/search/SearchByKeywordResultPage.java @@ -4,21 +4,32 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; +import java.util.List; + public class SearchByKeywordResultPage { WebDriver driver; @FindBy(css = ".news") private WebElement newsElement; - @FindBy(css = ".all") - private WebElement firstResultElement; + @FindBy(xpath = "//*[@id=\'block_left_pad\']/div/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr") + private List listResultElement; public SearchByKeywordResultPage(WebDriver driver) { this.driver = driver; } - public boolean isFirstResultElementPresent(String str) { - return firstResultElement.getText().toLowerCase().contains(str.toLowerCase()); + public boolean isFirstResultElementPresent(String text) { // + boolean matched = true; + + for (int i = 0; i < listResultElement.size()-1; i++) { + String str = listResultElement.get(i).getText(); + if((i-2) % 3 == 0 && !str.toLowerCase().contains(text.toLowerCase())){ + matched = false; + //break; + } + } + return matched; } public boolean isNewsElementPresent() { diff --git a/Skalkin/src/test/java/page/search/SearchExtendedResultPage.java b/Skalkin/src/test/java/page/search/SearchExtendedResultPage.java index f2d4feb..75c035d 100644 --- a/Skalkin/src/test/java/page/search/SearchExtendedResultPage.java +++ b/Skalkin/src/test/java/page/search/SearchExtendedResultPage.java @@ -4,6 +4,8 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; +import java.util.List; + public class SearchExtendedResultPage { WebDriver driver; @@ -11,28 +13,38 @@ public class SearchExtendedResultPage { private WebElement resultTopElement; @FindBy(xpath = "//a[@href='/film/koma-2018-933208/sr/1/']") - private WebElement firstResultElement; + private WebElement komaFromResultElement; @FindBy(xpath = "//a[@href='/name/224620/sr/1/']") - private WebElement actorResultElement; + private WebElement bezrukovFromResultElement; + + @FindBy(css = ".element") + private List usersListResultElement; + - @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 isUsersResultElementPresent(String text) { + boolean matched = true; + + for (int i = 0; i < usersListResultElement.size(); i++) { + if(!usersListResultElement.get(i).getText().toLowerCase().contains(text.toLowerCase())){ + matched = false; + break; + } + } + return matched; } - public boolean isActorResultElementPresent() { - return actorResultElement.isDisplayed(); + public boolean isBezrukovFromResultElementPresent() { + return bezrukovFromResultElement.isDisplayed(); } - public boolean isFirstResultElementPresent() { - return firstResultElement.isDisplayed(); + public boolean isKomaFromResultElementPresent() { + return komaFromResultElement.isDisplayed(); } public boolean isResultTopElementPresent() { diff --git a/Skalkin/src/test/java/page/search/SearchInTextResultPage.java b/Skalkin/src/test/java/page/search/SearchInTextResultPage.java index 9cb242f..c235576 100644 --- a/Skalkin/src/test/java/page/search/SearchInTextResultPage.java +++ b/Skalkin/src/test/java/page/search/SearchInTextResultPage.java @@ -4,6 +4,9 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; +import java.lang.reflect.Method; +import java.util.List; + public class SearchInTextResultPage { WebDriver driver; @@ -11,8 +14,10 @@ public class SearchInTextResultPage { private WebElement headerElement; @FindBy(css = ".news") - private WebElement newsElement; + private WebElement newsElement; // + @FindBy(xpath = "//*[@id='block_left_pad']/div/table/tbody/tr/td/table[2]/tbody/tr/td/table[2]/tbody/tr") + private List listNewsElement; public SearchInTextResultPage(WebDriver driver) { this.driver = driver; @@ -22,7 +27,15 @@ public class SearchInTextResultPage { return newsElement.getText(); } - public boolean isHeaderElementPresent() { - return headerElement.isDisplayed(); + public boolean isListElementPresent(String text) { + boolean matched = true; + + for (int i = 4; i < listNewsElement.size(); i++) { + if((i-1) % 3 == 0 && !listNewsElement.get(i).getText().toLowerCase().contains(text.toLowerCase())){ + matched = false; + break; + } + } + return matched; } }