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 @AfterAll
public static void quit() { public static void quit() {
context.close(); context.close();
} }

View File

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

View File

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

View File

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

View File

@ -22,7 +22,6 @@ public class ProductsTest {
@AfterAll @AfterAll
public static void quit() { public static void quit() {
context.close(); context.close();
} }
@ -34,7 +33,6 @@ public class ProductsTest {
pageMain.clickBasketIcon(); pageMain.clickBasketIcon();
Assertions.assertTrue(pageBasket.isBasketPagePresent()); Assertions.assertTrue(pageBasket.isBasketPagePresent());
pageBasket.clickLogo();
} }
@Test @Test
@ -46,7 +44,6 @@ public class ProductsTest {
pageMain.clickBasketIcon(); pageMain.clickBasketIcon();
pageBasket.clickDeleteSpan(); pageBasket.clickDeleteSpan();
Assertions.assertTrue(pageBasket.isBasketPagePresent()); Assertions.assertTrue(pageBasket.isBasketPagePresent());
pageBasket.clickLogo();
} }
@Test @Test
@ -66,6 +63,5 @@ public class ProductsTest {
pageOrder.setInputStringsAuth(inputStringMail, inputStringPhone, inputStringName); pageOrder.setInputStringsAuth(inputStringMail, inputStringPhone, inputStringName);
pageOrder.clickMakeOrderBtn(); pageOrder.clickMakeOrderBtn();
Assertions.assertTrue(pageOrder.isOrderPresent()); 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(); 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() { public void clickMainMenu() {
mainMenu.get(1).sendKeys(Keys.RETURN); mainMenu.get(1).sendKeys(Keys.RETURN);
@ -108,6 +108,10 @@ public class MainPage {
authReg.get(0).sendKeys(Keys.RETURN); authReg.get(0).sendKeys(Keys.RETURN);
} }
public void clickReg() {
authReg.get(1).sendKeys(Keys.RETURN);
}
public void clickBasketIcon() { public void clickBasketIcon() {
basketIcon.sendKeys(Keys.RETURN); basketIcon.sendKeys(Keys.RETURN);
} }

View File

@ -26,13 +26,24 @@ public class ProductPage {
@FindBy(id = "userComment") @FindBy(id = "userComment")
private WebElement inputReviewText; private WebElement inputReviewText;
@FindBy(css = ".text-cutter-wrapper")
private List<WebElement> titles;
public ProductPage(WebDriver driver) { public ProductPage(WebDriver driver) {
this.driver = driver; this.driver = driver;
} }
public boolean isProductMenuPresent() { return driver.getTitle().contains("отзывы"); } 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() { public void clickProductMenu() {
productMenu.get(2).sendKeys(Keys.RETURN); productMenu.get(2).sendKeys(Keys.RETURN);

View File

@ -20,6 +20,12 @@ public class SideMenuPage {
@FindBy(css = ".c-plp-facets__item-link") @FindBy(css = ".c-plp-facets__item-link")
private List<WebElement> points; 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") @FindBy(css = ".c-plp-facets__clear-wrapper .c-btn")
private WebElement clearBtn; private WebElement clearBtn;
@ -55,11 +61,19 @@ public class SideMenuPage {
mVideoLogo.sendKeys(Keys.RETURN); 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++) { 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);
} }
} }