Исправлены замечания

This commit is contained in:
StroevaJ 2018-05-11 22:52:22 +04:00
parent f7ab019a6e
commit 594b41c402
5 changed files with 42 additions and 13 deletions

View File

@ -34,7 +34,7 @@ public class FilterTests {
page.insertSearchText("Древние"); page.insertSearchText("Древние");
page.insertEnterSearchText(); page.insertEnterSearchText();
SearchPage pageAn = PageFactory.initElements(context.getDriver(), SearchPage.class); SearchPage pageAn = PageFactory.initElements(context.getDriver(), SearchPage.class);
Assertions.assertTrue(pageAn.isSearchPresent()); Assertions.assertTrue(pageAn.isSearchPresent("Древние"));
} }
@Test @Test

View File

@ -46,44 +46,49 @@ public class NavigationTests {
public void testRating() { public void testRating() {
context.getDriver().get(APP_URL); context.getDriver().get(APP_URL);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class); MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
String str = page.getRating();
page.clickRating(); page.clickRating();
NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class); NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class);
Assertions.assertTrue(pageAn.isContentPresent()); Assertions.assertTrue(pageAn.isContentPresent(str));
} }
@Test @Test
public void testYear() { public void testYear() {
context.getDriver().get(APP_URL); context.getDriver().get(APP_URL);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class); MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
String str = page.getYear();
page.clickYear(); page.clickYear();
NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class); NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class);
Assertions.assertTrue(pageAn.isContentPresent()); Assertions.assertTrue(pageAn.isContentPresent(str));
} }
@Test @Test
public void testCountry() { public void testCountry() {
context.getDriver().get(APP_URL); context.getDriver().get(APP_URL);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class); MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
String str = page.getCountry();
page.clickCountry(); page.clickCountry();
NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class); NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class);
Assertions.assertTrue(pageAn.isContentPresent()); Assertions.assertTrue(pageAn.isContentPresent(str));
} }
@Test @Test
public void testGenre() { public void testGenre() {
context.getDriver().get(APP_URL); context.getDriver().get(APP_URL);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class); MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
String str = page.getGenre();
page.clickGenre(); page.clickGenre();
NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class); NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class);
Assertions.assertTrue(pageAn.isContentPresent()); Assertions.assertTrue(pageAn.isContentPresent(str));
} }
@Test @Test
public void testMenu() { public void testMenu() {
context.getDriver().get(APP_URL); context.getDriver().get(APP_URL);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class); MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
String str = page.getElementMenu();
page.clickMenu(); page.clickMenu();
NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class); NavFilterPage pageAn = PageFactory.initElements(context.getDriver(), NavFilterPage.class);
Assertions.assertTrue(pageAn.isContentPresent()); Assertions.assertTrue(pageAn.isPagePresent(str));
} }
} }

View File

@ -71,6 +71,26 @@ public class MainPage {
menuElement.click(); 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() { public boolean isFilterPresent() {
return filterElement.isDisplayed(); return filterElement.isDisplayed();
} }

View File

@ -7,14 +7,18 @@ import org.openqa.selenium.support.FindBy;
public class NavFilterPage { public class NavFilterPage {
WebDriver driver; WebDriver driver;
@FindBy(id = "dle-content") @FindBy(xpath = "/html/body/div[1]/div[2]/div[2]/h1")
private WebElement contentElement; private WebElement title;
public NavFilterPage(WebDriver driver) { public NavFilterPage(WebDriver driver) {
this.driver = driver; this.driver = driver;
} }
public boolean isContentPresent() { public boolean isPagePresent(String str) {
return contentElement.isDisplayed(); return driver.getTitle().toUpperCase().contains(str.toUpperCase());
}
public boolean isContentPresent(String str) {
return title.getText().toUpperCase().contains(str.toUpperCase());
} }
} }

View File

@ -7,14 +7,14 @@ import org.openqa.selenium.support.FindBy;
public class SearchPage { public class SearchPage {
WebDriver driver; WebDriver driver;
@FindBy(css = ".res-search") @FindBy(xpath = "//*[@id=\"serials\"]/div/div[2]/div[1]")
private WebElement searchElement; private WebElement searchElement;
public SearchPage(WebDriver driver) { public SearchPage(WebDriver driver) {
this.driver = driver; this.driver = driver;
} }
public boolean isSearchPresent() { public boolean isSearchPresent(String str) {
return searchElement.isDisplayed(); return searchElement.getText().contains(str);
} }
} }