Edited tests

This commit is contained in:
mrHewd 2018-04-28 12:00:44 +03:00
parent af20c87fdc
commit 4d31ca6f2b
8 changed files with 80 additions and 60 deletions

View File

@ -23,7 +23,6 @@ public class AccountTest {
@AfterAll
public static void quit() {
context.close();
}

View File

@ -22,23 +22,22 @@ public class FeedbackTest {
@AfterAll
public static void quit() {
context.close();
}
@Test
public void testFollow() {
public void testSubscribe() {
context.getDriver().get(APP_URL_MVideo);
String inputStringMail = "test543321@mail.ru";
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
pageMain.setEmail(inputStringMail);
pageMain.clickSubmitSub();
Assertions.assertTrue(pageMain.isFollowSuccess());
Assertions.assertTrue(pageMain.isSubSuccess());
}
@Test
public void testProductMenu() {
public void testLeaveReview() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class);
@ -54,6 +53,5 @@ public class FeedbackTest {
pageProduct.clickLeaveReviewBtn();
pageProduct.setReviewData(eMail, text);
Assertions.assertTrue(pageProduct.isProductMenuPresent());
pageMain.clickLogo();
}
}

View File

@ -29,40 +29,40 @@ public class FiltersTest {
@AfterAll
public static void quit() {
context.close();
}
@Test
public void testSearch() {
context.getDriver().get(APP_URL_MVideo);
String searchString = "телевизор samsung";
String searchString = "Телевизор Samsung";
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
ProductPage pageProduct = PageFactory.initElements(context.getDriver(), ProductPage.class);
pageMain.setSearchString(searchString);
pageMain.clickSubmitButton();
Assertions.assertTrue(pageProduct.isProductPresent());
pageMain.clickLogo();
Assertions.assertTrue(pageProduct.isProductCorrect(searchString));
}
@Test
public void testProductOneCategoryOnePoint() {
context.getDriver().get(APP_URL_MVideo);
int point = 1;
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class);
SideMenuPage pageFilter = PageFactory.initElements(context.getDriver(), SideMenuPage.class);
pageMain.clickMainMenu();
pageMainMenu.clickTV();
pageFilter.clickPoint(5);
pageFilter.clickCategoryPoint(point);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
pageFilter.clickLogo();
}
@Test
public void testProductOneCategoryTwoPoints() {
context.getDriver().get(APP_URL_MVideo);
int firstCategoryPoint = 1;
int secondCategoryPoint = 2;
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class);
@ -70,33 +70,35 @@ public class FiltersTest {
pageMain.clickMainMenu();
pageMainMenu.clickTV();
point.clear();
point.add(5);
point.add(6);
pageFilter.clickPoints(point);
point.add(firstCategoryPoint);
point.add(secondCategoryPoint);
pageFilter.clickCategoryTwoPoints(point);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
pageFilter.clickLogo();
}
@Test
public void testProductTwoCategoryOnePoint() {
context.getDriver().get(APP_URL_MVideo);
int categoryPoint = 1;
int brandPoint = 2;
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class);
SideMenuPage pageFilter = PageFactory.initElements(context.getDriver(), SideMenuPage.class);
pageMain.clickMainMenu();
pageMainMenu.clickTV();
point.clear();
point.add(3);
point.add(6);
pageFilter.clickPoints(point);
pageFilter.clickCategoryPoint(categoryPoint);
pageFilter.clickBrandPoint(brandPoint);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
pageFilter.clickLogo();
}
@Test
public void testProductTwoCategoryTwoPoints() {
context.getDriver().get(APP_URL_MVideo);
int firstCategoryPoint = 1;
int secondCategoryPoint = 2;
int firstBrandPoint = 2;
int secondBrandPoint = 4;
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class);
@ -104,31 +106,34 @@ public class FiltersTest {
pageMain.clickMainMenu();
pageMainMenu.clickTV();
point.clear();
point.add(3);
point.add(4);
point.add(6);
point.add(7);
pageFilter.clickPoints(point);
point.add(firstCategoryPoint);
point.add(secondCategoryPoint);
pageFilter.clickCategoryTwoPoints(point);
point.clear();
point.add(firstBrandPoint);
point.add(secondBrandPoint);
pageFilter.clickBrandTwoPoints(point);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
pageFilter.clickLogo();
}
@Test
public void testProductCombine() {
context.getDriver().get(APP_URL_MVideo);
int categoryPoint = 1;
int firstBrandPoint = 1;
int secondBrandPoint = 3;
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class);
SideMenuPage pageFilter = PageFactory.initElements(context.getDriver(), SideMenuPage.class);
pageMain.clickMainMenu();
pageMainMenu.clickTV();
pageFilter.clickCategoryPoint(categoryPoint);
point.clear();
point.add(3);
point.add(6);
point.add(4);
pageFilter.clickPoints(point);
point.add(firstBrandPoint);
point.add(secondBrandPoint);
pageFilter.clickBrandTwoPoints(point);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
pageFilter.clickLogo();
}
@Test
@ -142,7 +147,6 @@ public class FiltersTest {
pageMainMenu.clickTV();
pageFilter.selectAttribute();
Assertions.assertTrue(pageFilter.isProductContainsPoint());
pageMain.clickLogo();
}
@Test
@ -158,7 +162,6 @@ public class FiltersTest {
pageMainMenu.clickTV();
pageFilter.setPrice(minPriceText, maxPriceText);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
pageMain.clickLogo();
}
@Test
@ -173,13 +176,16 @@ public class FiltersTest {
pageMainMenu.clickTV();
pageSideMenu.clickProduct();
pageProduct.clickFavorite();
// Assertions.assertTrue(pageProduct.isProductMenuPresent());
// pageMain.clickLogo();
Assertions.assertTrue(pageProduct.isProductMenuPresent());
}
@Test
public void testClearCriteria() {
context.getDriver().get(APP_URL_MVideo);
int firstCategoryPoint = 1;
int secondCategoryPoint = 2;
int firstBrandPoint = 2;
int secondBrandPoint = 4;
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class);
@ -187,13 +193,14 @@ public class FiltersTest {
pageMain.clickMainMenu();
pageMainMenu.clickTV();
point.clear();
point.add(3);
point.add(4);
point.add(6);
point.add(7);
pageFilter.clickPoints(point);
point.add(firstCategoryPoint);
point.add(secondCategoryPoint);
pageFilter.clickCategoryTwoPoints(point);
point.clear();
point.add(firstBrandPoint);
point.add(secondBrandPoint);
pageFilter.clickBrandTwoPoints(point);
pageFilter.clickClearBtn();
Assertions.assertTrue(pageFilter.isProductContainsPoint());
pageFilter.clickLogo();
}
}

View File

@ -22,7 +22,6 @@ public class NavigationTest {
@AfterAll
public static void quit() {
context.close();
}
@ -43,7 +42,6 @@ public class NavigationTest {
pageMain.clickMainMenu();
Assertions.assertTrue(pageMainMenu.isMainMenuPresent());
pageMain.clickLogo();
}
@Test
@ -54,7 +52,6 @@ public class NavigationTest {
pageMain.clickSubMenu();
Assertions.assertTrue(pageSubMenu.isSubMenuPresent());
pageMain.clickLogo();
}
@Test
@ -65,7 +62,6 @@ public class NavigationTest {
pageMain.clickFooterMenu();
Assertions.assertTrue(pageFooter.isFooterMenuPresent());
pageMain.clickLogo();
}
@Test
@ -76,7 +72,6 @@ public class NavigationTest {
pageMain.clickReadMore();
Assertions.assertTrue(pageReadMore.isReadMorePresent());
pageMain.clickLogo();
}
@Test
@ -85,7 +80,6 @@ public class NavigationTest {
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
pageMain.clickSocialLink();
pageMain.clickLogo();
}
@Test
@ -96,7 +90,6 @@ public class NavigationTest {
pageMain.clickReviews();
Assertions.assertTrue(pageReviews.areReviewsPresent());
pageMain.clickLogo();
}
@Test
@ -109,7 +102,6 @@ public class NavigationTest {
pageMain.clickMainMenu();
pageMainMenu.clickTV();
Assertions.assertTrue(pageSideBar.isSideBarPresent());
pageMain.clickLogo();
}
@Test
@ -125,6 +117,5 @@ public class NavigationTest {
pageSideMenu.clickProduct();
pageProduct.clickProductMenu();
Assertions.assertTrue(pageProduct.isProductMenuPresent());
pageMain.clickLogo();
}
}

View File

@ -22,7 +22,6 @@ public class ProductsTest {
@AfterAll
public static void quit() {
context.close();
}
@ -34,7 +33,6 @@ public class ProductsTest {
pageMain.clickBasketIcon();
Assertions.assertTrue(pageBasket.isBasketPagePresent());
pageBasket.clickLogo();
}
@Test
@ -46,7 +44,6 @@ public class ProductsTest {
pageMain.clickBasketIcon();
pageBasket.clickDeleteSpan();
Assertions.assertTrue(pageBasket.isBasketPagePresent());
pageBasket.clickLogo();
}
@Test
@ -66,6 +63,5 @@ public class ProductsTest {
pageOrder.setInputStringsAuth(inputStringMail, inputStringPhone, inputStringName);
pageOrder.clickMakeOrderBtn();
Assertions.assertTrue(pageOrder.isOrderPresent());
pageOrder.clickLogo();
}
}

View File

@ -58,7 +58,7 @@ public class MainPage {
return driver.findElement(By.cssSelector(".my-account-personal-photo-placeholder")).isDisplayed();
}
public boolean isFollowSuccess() { return driver.findElement(By.cssSelector(".text-success")).isDisplayed(); }
public boolean isSubSuccess() { return driver.findElement(By.cssSelector(".text-success")).isDisplayed(); }
public void clickMainMenu() {
mainMenu.get(1).sendKeys(Keys.RETURN);
@ -108,6 +108,10 @@ public class MainPage {
authReg.get(0).sendKeys(Keys.RETURN);
}
public void clickReg() {
authReg.get(1).sendKeys(Keys.RETURN);
}
public void clickBasketIcon() {
basketIcon.sendKeys(Keys.RETURN);
}

View File

@ -26,13 +26,24 @@ public class ProductPage {
@FindBy(id = "userComment")
private WebElement inputReviewText;
@FindBy(css = ".text-cutter-wrapper")
private List<WebElement> titles;
public ProductPage(WebDriver driver) {
this.driver = driver;
}
public boolean isProductMenuPresent() { return driver.getTitle().contains("отзывы"); }
public boolean isProductPresent() { return driver.findElement(By.cssSelector(".product-tile")).isDisplayed(); }
public boolean isProductCorrect(String searchString) {
boolean correct = true;
for (int i = 0; i < titles.size(); i++) {
if (!titles.get(i).getText().contains(searchString)) {
correct = false;
}
}
return correct;
}
public void clickProductMenu() {
productMenu.get(2).sendKeys(Keys.RETURN);

View File

@ -20,6 +20,12 @@ public class SideMenuPage {
@FindBy(css = ".c-plp-facets__item-link")
private List<WebElement> points;
@FindBy(css = "#category-section .c-plp-facets__item-link")
private List<WebElement> categoryPoints;
@FindBy(css = "#brand-section .c-plp-facets__item-link")
private List<WebElement> brandPoints;
@FindBy(css = ".c-plp-facets__clear-wrapper .c-btn")
private WebElement clearBtn;
@ -55,11 +61,19 @@ public class SideMenuPage {
mVideoLogo.sendKeys(Keys.RETURN);
}
public void clickPoint(int point) { points.get(point).sendKeys(Keys.RETURN); }
public void clickCategoryPoint(int point) { categoryPoints.get(point).sendKeys(Keys.RETURN); }
public void clickPoints(List<Integer> point) {
public void clickBrandPoint(int point) { brandPoints.get(point).sendKeys(Keys.RETURN); }
public void clickCategoryTwoPoints(List<Integer> point) {
for (int i = 0; i < point.size(); i++) {
points.get(point.get(i)).sendKeys(Keys.RETURN);
categoryPoints.get(point.get(i)).sendKeys(Keys.RETURN);
}
}
public void clickBrandTwoPoints(List<Integer> point) {
for (int i = 0; i < point.size(); i++) {
brandPoints.get(point.get(i)).sendKeys(Keys.RETURN);
}
}