Skalkin #6

Closed
antonskalkin73 wants to merge 9 commits from Skalkin into master
5 changed files with 62 additions and 25 deletions
Showing only changes of commit 76e1d98652 - Show all commits

View File

@ -36,7 +36,7 @@ public class SearchTests {
page.enterSearch(); page.enterSearch();
SearchExtendedResultPage pageTo = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница SearchExtendedResultPage pageTo = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница
Assertions.assertTrue(pageTo.isFirstResultElementPresent()); Assertions.assertTrue(pageTo.isKomaFromResultElementPresent());
} }
@Test @Test
@ -50,7 +50,7 @@ public class SearchTests {
page.enterSearch(); page.enterSearch();
SearchExtendedResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница SearchExtendedResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница
Assertions.assertTrue(pageResult.isFirstResultElementPresent()); Assertions.assertTrue(pageResult.isKomaFromResultElementPresent());
} }
@Test @Test
@ -66,7 +66,7 @@ public class SearchTests {
page.enterSearch(); page.enterSearch();
SearchByCreatorsResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchByCreatorsResultPage.class);//Корректно отображена выбранная страница SearchByCreatorsResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchByCreatorsResultPage.class);//Корректно отображена выбранная страница
Assertions.assertTrue(pageResult.isFirstResultCreatorsPresent()); Assertions.assertTrue(pageResult.isBrigadaFromResultCreatorsPresent());
} }
@Test @Test
@ -78,7 +78,7 @@ public class SearchTests {
page.enterSearch(); page.enterSearch();
SearchExtendedResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница SearchExtendedResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchExtendedResultPage.class);//Корректно отображена выбранная страница
Assertions.assertTrue(pageResult.isActorResultElementPresent()); Assertions.assertTrue(pageResult.isBezrukovFromResultElementPresent());
} }
@Test @Test
@ -91,7 +91,8 @@ public class SearchTests {
SearchInTextResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchInTextResultPage.class);//Корректно отображена выбранная страница SearchInTextResultPage pageResult = PageFactory.initElements(context.getDriver(), SearchInTextResultPage.class);//Корректно отображена выбранная страница
String str = pageResult.getNewsElementToString(); String str = pageResult.getNewsElementToString();
Assertions.assertTrue(pageResult.getNewsElementToString().contains("Веном"));
Assertions.assertTrue(pageResult.isListElementPresent("Веном"));
} }
@Test @Test

View File

@ -11,7 +11,7 @@ public class SearchByCreatorsResultPage {
private WebElement resultCreatorsElement; private WebElement resultCreatorsElement;
@FindBy(xpath = "//a[@href='/film/brigada-2002-77039/sr/1/']") @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/']") @FindBy(xpath = "//a[@href='/film/garri-potter-i-filosofskiy-kamen-2001-689/sr/1/']")
private WebElement firstResultByWordElement; private WebElement firstResultByWordElement;
@ -24,8 +24,8 @@ public class SearchByCreatorsResultPage {
return firstResultByWordElement.isDisplayed(); return firstResultByWordElement.isDisplayed();
} }
public boolean isFirstResultCreatorsPresent() { public boolean isBrigadaFromResultCreatorsPresent() {
return firstResultCreatorsElement.isDisplayed(); return brigadaFromResultCreatorsElement.isDisplayed();
} }
public boolean isResultCreatorsPresent() { public boolean isResultCreatorsPresent() {

View File

@ -4,21 +4,32 @@ import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import java.util.List;
public class SearchByKeywordResultPage { public class SearchByKeywordResultPage {
WebDriver driver; WebDriver driver;
@FindBy(css = ".news") @FindBy(css = ".news")
private WebElement newsElement; private WebElement newsElement;
@FindBy(css = ".all") @FindBy(xpath = "//*[@id=\'block_left_pad\']/div/table/tbody/tr/td/table[2]/tbody/tr/td/table[1]/tbody/tr")
private WebElement firstResultElement; private List<WebElement> listResultElement;
public SearchByKeywordResultPage(WebDriver driver) { public SearchByKeywordResultPage(WebDriver driver) {
this.driver = driver; this.driver = driver;
} }
public boolean isFirstResultElementPresent(String str) { public boolean isFirstResultElementPresent(String text) { //
return firstResultElement.getText().toLowerCase().contains(str.toLowerCase()); 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() { public boolean isNewsElementPresent() {

View File

@ -4,6 +4,8 @@ import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import java.util.List;
public class SearchExtendedResultPage { public class SearchExtendedResultPage {
WebDriver driver; WebDriver driver;
@ -11,28 +13,38 @@ public class SearchExtendedResultPage {
private WebElement resultTopElement; private WebElement resultTopElement;
@FindBy(xpath = "//a[@href='/film/koma-2018-933208/sr/1/']") @FindBy(xpath = "//a[@href='/film/koma-2018-933208/sr/1/']")
private WebElement firstResultElement; private WebElement komaFromResultElement;
@FindBy(xpath = "//a[@href='/name/224620/sr/1/']") @FindBy(xpath = "//a[@href='/name/224620/sr/1/']")
private WebElement actorResultElement; private WebElement bezrukovFromResultElement;
@FindBy(css = ".element")
private List<WebElement> usersListResultElement;
@FindBy(css = ".gray")
private WebElement usersResultElement;
public SearchExtendedResultPage(WebDriver driver) { public SearchExtendedResultPage(WebDriver driver) {
this.driver = driver; this.driver = driver;
} }
public boolean isUsersResultElementPresent(String str) { public boolean isUsersResultElementPresent(String text) {
return usersResultElement.getText().contains(str); 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() { public boolean isBezrukovFromResultElementPresent() {
return actorResultElement.isDisplayed(); return bezrukovFromResultElement.isDisplayed();
} }
public boolean isFirstResultElementPresent() { public boolean isKomaFromResultElementPresent() {
return firstResultElement.isDisplayed(); return komaFromResultElement.isDisplayed();
} }
public boolean isResultTopElementPresent() { public boolean isResultTopElementPresent() {

View File

@ -4,6 +4,9 @@ import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import java.lang.reflect.Method;
import java.util.List;
public class SearchInTextResultPage { public class SearchInTextResultPage {
WebDriver driver; WebDriver driver;
@ -11,8 +14,10 @@ public class SearchInTextResultPage {
private WebElement headerElement; private WebElement headerElement;
@FindBy(css = ".news") @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<WebElement> listNewsElement;
public SearchInTextResultPage(WebDriver driver) { public SearchInTextResultPage(WebDriver driver) {
this.driver = driver; this.driver = driver;
@ -22,7 +27,15 @@ public class SearchInTextResultPage {
return newsElement.getText(); return newsElement.getText();
} }
public boolean isHeaderElementPresent() { public boolean isListElementPresent(String text) {
return headerElement.isDisplayed(); 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;
} }
} }