This commit is contained in:
alexandrakrav 2018-10-11 20:27:06 +04:00
parent 181581f3bc
commit 7e349a72ec
5 changed files with 42 additions and 44 deletions

View File

@ -52,6 +52,9 @@ public class ExternalLinks {
AboutCompanyPage aboutPage = PageFactory.initElements(context.getDriver(), AboutCompanyPage.class); AboutCompanyPage aboutPage = PageFactory.initElements(context.getDriver(), AboutCompanyPage.class);
aboutPage.clickShareElement(); aboutPage.clickShareElement();
aboutPage.isPageDisplaySubmitButton(); aboutPage.isPageDisplaySubmitButton();
Assertions.assertTrue(aboutPage.isPageDisplaySubmitButton());
} }

View File

@ -12,7 +12,7 @@ import page.*;
public class Search { public class Search {
private final static String APP_URL = "http://www.sberbank-ast.ru/"; private final static String APP_URL = "http://www.sberbank-ast.ru/";
private static Context context; private static Context context;
String search = "Поставка";
@BeforeAll @BeforeAll
public static void setup() { public static void setup() {
@ -29,31 +29,31 @@ public class Search {
public void searchHeaderTest() { public void searchHeaderTest() {
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);
page.insertSearchHeaderText("Поставка"); page.insertSearchHeaderText(search);
page.submitSearchHeader(); page.submitSearchHeader();
SearchPage searchPage = PageFactory.initElements(context.getDriver(), SearchPage.class); SearchPage searchPage = PageFactory.initElements(context.getDriver(), SearchPage.class);
Assertions.assertTrue(searchPage.checkSearch()); Assertions.assertTrue(searchPage.checkSearch(search));
} }
@Test @Test
public void searchHeaderTestWithFilter() { public void searchHeaderTestWithFilter() throws RuntimeException{
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);
page.insertSearchHeaderText("Поставка"); page.insertSearchHeaderText(search);
page.submitSearchHeader(); page.submitSearchHeader();
SearchPage searchPage = PageFactory.initElements(context.getDriver(), SearchPage.class); SearchPage searchPage = PageFactory.initElements(context.getDriver(), SearchPage.class);
searchPage.clickSearchFilter(); searchPage.clickSearchFilter();
Assertions.assertTrue(searchPage.checkSearch()); Assertions.assertTrue(searchPage.checkSearch(search));
Assertions.assertTrue(searchPage.checkFilter()); Assertions.assertTrue(searchPage.checkFilter());
} }
@Test @Test
public void searchHeaderTestWithSorting() { public void searchHeaderTestWithSorting() {
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);
page.insertSearchHeaderText("Поставка"); page.insertSearchHeaderText(search);
page.submitSearchHeader(); page.submitSearchHeader();
SearchPage searchPage = PageFactory.initElements(context.getDriver(), SearchPage.class); SearchPage searchPage = PageFactory.initElements(context.getDriver(), SearchPage.class);
searchPage.clickSearchSortingElement(); searchPage.clickSearchSortingElement();
Assertions.assertTrue(searchPage.checkSearch()); Assertions.assertTrue(searchPage.checkSearch(search));
} }
@Test @Test

View File

@ -4,30 +4,35 @@ import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver; 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 org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
public class AboutCompanyPage { public class AboutCompanyPage {
WebDriver driver; private WebDriver driver ;
private WebDriverWait wait;
public AboutCompanyPage(WebDriver driver) {
this.driver = driver;
wait = new WebDriverWait(driver,30,500);
}
@FindBy(xpath = "//*[@id=\"blockFacebook\"]/div/span/iframe") @FindBy(xpath = "//*[@id=\"blockFacebook\"]/div/span/iframe")
private WebElement shareFrame; private WebElement shareFrame;
@FindBy(css = "#u_0_3 > button") @FindBy(css = "#u_0_3 > button")
private WebElement shareButton; private WebElement shareButton;
public void clickShareElement() { public void clickShareElement(){
wait.until(ExpectedConditions.visibilityOf(shareFrame));
driver.switchTo().frame(shareFrame); driver.switchTo().frame(shareFrame);
sleep();
shareButton.click(); shareButton.click();
sleep();
for (String winHandle : driver.getWindowHandles()) { for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle); driver.switchTo().window(winHandle);
} }
} }
public AboutCompanyPage(WebDriver driver) {
this.driver = driver;
}
public boolean isPageDisplayQuality() { public boolean isPageDisplayQuality() {
return driver.findElement(By.cssSelector("#ctl00_phWorkZone_ContentItem_lblbody")).isDisplayed(); return driver.findElement(By.cssSelector("#ctl00_phWorkZone_ContentItem_lblbody")).isDisplayed();
@ -38,12 +43,5 @@ public class AboutCompanyPage {
return driver.findElement(By.cssSelector("#u_0_0")).isDisplayed(); return driver.findElement(By.cssSelector("#u_0_0")).isDisplayed();
} }
public void sleep() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} }

View File

@ -4,10 +4,13 @@ import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.*; import org.openqa.selenium.*;
import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class MainPage { public class MainPage {
String headline = ""; String headline = "";
WebDriver driver; WebDriver driver;
private WebDriverWait wait;
@FindBy(css = "#response_slider_wrap iframe") @FindBy(css = "#response_slider_wrap iframe")
private WebElement feedbackFrame; private WebElement feedbackFrame;
@ -119,6 +122,7 @@ public class MainPage {
private WebElement documentsSubmenuElement; private WebElement documentsSubmenuElement;
public MainPage(WebDriver driver) { public MainPage(WebDriver driver) {
this.driver = driver; this.driver = driver;
wait = new WebDriverWait(driver,30,5000);
} }
public void clickMoreInformation() { public void clickMoreInformation() {
@ -160,13 +164,10 @@ public class MainPage {
} }
public void clickFeedbackElement() { public void clickFeedbackElement() {
FeedbackElement.click(); FeedbackElement.click();
try { wait.until(ExpectedConditions.visibilityOf(feedbackFrame));
Thread.sleep(5000);
driver.switchTo().frame(feedbackFrame); driver.switchTo().frame(feedbackFrame);
AllFeedbackElement.click(); AllFeedbackElement.click();
} catch (InterruptedException e) {
e.printStackTrace();
}
} }

View File

@ -56,15 +56,12 @@ public class SearchPage {
} }
public void clickSearchSortingElement() { public void clickSearchSortingElement() {
searchSortingElement.click(); searchSortingElement.click();
} }
public boolean checkSearch() { public boolean checkSearch(String strSearch) {
boolean checkSearch = false; boolean checkSearch = false;
int count = listResultSearch.size(); int count = listResultSearch.size();
String strSearch = searchHeaderElement.getAttribute("value");
for (int i = 0; i < count - 1; i++) { for (int i = 0; i < count - 1; i++) {
if (listResultSearch.get(i).getText().contains(strSearch)) if (listResultSearch.get(i).getText().contains(strSearch))
checkSearch = true; checkSearch = true;
@ -76,9 +73,8 @@ public class SearchPage {
public boolean checkFilter() public boolean checkFilter()
{ {
double b = Math.round(Double.parseDouble(resultElement.getText().replaceAll(" ", ""))); double b = Math.round(Double.parseDouble(resultElement.getText().replaceAll(" ", "")));
if (b > pr) return b > pr;
return true;
else return false;
} }