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);
aboutPage.clickShareElement();
aboutPage.isPageDisplaySubmitButton();
Assertions.assertTrue(aboutPage.isPageDisplaySubmitButton());
}

View File

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

View File

@ -4,30 +4,35 @@ import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
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 {
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")
private WebElement shareFrame;
@FindBy(css = "#u_0_3 > button")
private WebElement shareButton;
public void clickShareElement() {
public void clickShareElement(){
wait.until(ExpectedConditions.visibilityOf(shareFrame));
driver.switchTo().frame(shareFrame);
sleep();
shareButton.click();
sleep();
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle);
}
}
public AboutCompanyPage(WebDriver driver) {
this.driver = driver;
}
public boolean isPageDisplayQuality() {
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();
}
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.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class MainPage {
String headline = "";
WebDriver driver;
private WebDriverWait wait;
@FindBy(css = "#response_slider_wrap iframe")
private WebElement feedbackFrame;
@ -119,6 +122,7 @@ public class MainPage {
private WebElement documentsSubmenuElement;
public MainPage(WebDriver driver) {
this.driver = driver;
wait = new WebDriverWait(driver,30,5000);
}
public void clickMoreInformation() {
@ -160,13 +164,10 @@ public class MainPage {
}
public void clickFeedbackElement() {
FeedbackElement.click();
try {
Thread.sleep(5000);
wait.until(ExpectedConditions.visibilityOf(feedbackFrame));
driver.switchTo().frame(feedbackFrame);
AllFeedbackElement.click();
} catch (InterruptedException e) {
e.printStackTrace();
}
}

View File

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