Compare commits

...

5 Commits

Author SHA1 Message Date
mrHewd
4d31ca6f2b Edited tests 2018-04-28 12:00:44 +03:00
mrHewd
af20c87fdc Added tests, pages 2018-04-28 00:07:57 +03:00
mrHewd
224df21352 Added new tests 2018-04-05 13:25:58 +03:00
mrHewd
c8b5fa7356 Laba2v1 2018-03-17 15:50:53 +03:00
Vasin Anton Olegovych
ad6da28d39 Add new directory 2018-03-17 11:07:03 +00:00
21 changed files with 1040 additions and 78 deletions

View File

@ -0,0 +1,42 @@
import context.ChromeContext;
import context.Context;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.support.PageFactory;
import page.AuthPage;
import page.MainPage;
public class AccountTest {
private final static String APP_URL_MVideo = "https://www.mvideo.ru/";
private static Context context;
@BeforeAll
public static void setup() {
context = new ChromeContext();
context.start();
context.getDriver().manage().window().setSize(new Dimension(1366, 768));
}
@AfterAll
public static void quit() {
context.close();
}
@Test
public void testAuth() {
context.getDriver().get(APP_URL_MVideo);
String inputStringMail = "test543321@mail.ru";
String inputStringPassword = "1234qwerQWER";
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
AuthPage pageAuth = PageFactory.initElements(context.getDriver(), AuthPage.class);
pageMain.clickAuth();
pageAuth.setInputStrings(inputStringMail, inputStringPassword);
pageAuth.clickSubmitButton();
Assertions.assertTrue(pageMain.isAccountPresent());
}
}

View File

@ -0,0 +1,57 @@
import context.ChromeContext;
import context.Context;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.support.PageFactory;
import page.*;
public class FeedbackTest {
private final static String APP_URL_MVideo = "https://www.mvideo.ru/";
private static Context context;
@BeforeAll
public static void setup() {
context = new ChromeContext();
context.start();
context.getDriver().manage().window().setSize(new Dimension(1366, 768));
}
@AfterAll
public static void quit() {
context.close();
}
@Test
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.isSubSuccess());
}
@Test
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);
SideMenuPage pageSideMenu = PageFactory.initElements(context.getDriver(), SideMenuPage.class);
ProductPage pageProduct = PageFactory.initElements(context.getDriver(), ProductPage.class);
String eMail = "test543321@mail.ru";
String text = "тест";
pageMain.clickMainMenu();
pageMainMenu.clickTV();
pageSideMenu.clickProduct();
pageProduct.clickProductMenu();
pageProduct.clickLeaveReviewBtn();
pageProduct.setReviewData(eMail, text);
Assertions.assertTrue(pageProduct.isProductMenuPresent());
}
}

View File

@ -0,0 +1,206 @@
import context.ChromeContext;
import context.Context;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.support.PageFactory;
import page.MainMenuPage;
import page.MainPage;
import page.ProductPage;
import page.SideMenuPage;
import java.util.ArrayList;
import java.util.List;
public class FiltersTest {
private final static String APP_URL_MVideo = "https://www.mvideo.ru/";
private static Context context;
List<Integer> point = new ArrayList<Integer>();
@BeforeAll
public static void setup() {
context = new ChromeContext();
context.start();
context.getDriver().manage().window().setSize(new Dimension(1366, 768));
}
@AfterAll
public static void quit() {
context.close();
}
@Test
public void testSearch() {
context.getDriver().get(APP_URL_MVideo);
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.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.clickCategoryPoint(point);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
}
@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);
SideMenuPage pageFilter = PageFactory.initElements(context.getDriver(), SideMenuPage.class);
pageMain.clickMainMenu();
pageMainMenu.clickTV();
point.clear();
point.add(firstCategoryPoint);
point.add(secondCategoryPoint);
pageFilter.clickCategoryTwoPoints(point);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
}
@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();
pageFilter.clickCategoryPoint(categoryPoint);
pageFilter.clickBrandPoint(brandPoint);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
}
@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);
SideMenuPage pageFilter = PageFactory.initElements(context.getDriver(), SideMenuPage.class);
pageMain.clickMainMenu();
pageMainMenu.clickTV();
point.clear();
point.add(firstCategoryPoint);
point.add(secondCategoryPoint);
pageFilter.clickCategoryTwoPoints(point);
point.clear();
point.add(firstBrandPoint);
point.add(secondBrandPoint);
pageFilter.clickBrandTwoPoints(point);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
}
@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(firstBrandPoint);
point.add(secondBrandPoint);
pageFilter.clickBrandTwoPoints(point);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
}
@Test
public void testSort() {
context.getDriver().get(APP_URL_MVideo);
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.selectAttribute();
Assertions.assertTrue(pageFilter.isProductContainsPoint());
}
@Test
public void testPrice() {
context.getDriver().get(APP_URL_MVideo);
String minPriceText = "10000";
String maxPriceText = "50000";
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.setPrice(minPriceText, maxPriceText);
Assertions.assertTrue(pageFilter.isProductContainsPoint());
}
@Test
public void testFavorite() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class);
SideMenuPage pageSideMenu = PageFactory.initElements(context.getDriver(), SideMenuPage.class);
ProductPage pageProduct = PageFactory.initElements(context.getDriver(), ProductPage.class);
pageMain.clickMainMenu();
pageMainMenu.clickTV();
pageSideMenu.clickProduct();
pageProduct.clickFavorite();
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);
SideMenuPage pageFilter = PageFactory.initElements(context.getDriver(), SideMenuPage.class);
pageMain.clickMainMenu();
pageMainMenu.clickTV();
point.clear();
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());
}
}

View File

@ -1,40 +0,0 @@
import context.ChromeContext;
import context.Context;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.support.PageFactory;
import page.SearchPage;
public class GithubUserSearch {
private final static String APP_URL = "https://github.com/";
private static Context context;
@BeforeAll
public static void setup() {
context = new ChromeContext();
context.start();
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
}
@AfterAll
public static void quit() {
context.close();
}
@Test
public void testResultPageHeader() {
context.getDriver().get(APP_URL);
String searchString = "romanov73";
SearchPage page = PageFactory.initElements(context.getDriver(), SearchPage.class);
page.setSearchString(searchString);
page.clickSubmitButton();
page.clickUsersLink();
Assertions.assertTrue(page.isUserPresent());
}
}

View File

@ -0,0 +1,121 @@
import context.ChromeContext;
import context.Context;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.support.PageFactory;
import page.*;
public class NavigationTest {
private final static String APP_URL_MVideo = "https://www.mvideo.ru/";
private static Context context;
@BeforeAll
public static void setup() {
context = new ChromeContext();
context.start();
context.getDriver().manage().window().setSize(new Dimension(1366, 768));
}
@AfterAll
public static void quit() {
context.close();
}
@Test
public void testLogo() {
context.getDriver().get(APP_URL_MVideo);
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
page.clickLogo();
Assertions.assertTrue(page.isLogoPresent());
}
@Test
public void testNavigationMainMenu() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class);
pageMain.clickMainMenu();
Assertions.assertTrue(pageMainMenu.isMainMenuPresent());
}
@Test
public void testNavigationSubMenu() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
SubMenuPage pageSubMenu = PageFactory.initElements(context.getDriver(), SubMenuPage.class);
pageMain.clickSubMenu();
Assertions.assertTrue(pageSubMenu.isSubMenuPresent());
}
@Test
public void testNavigationFooterMenu() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
FooterMenuPage pageFooter = PageFactory.initElements(context.getDriver(), FooterMenuPage.class);
pageMain.clickFooterMenu();
Assertions.assertTrue(pageFooter.isFooterMenuPresent());
}
@Test
public void testNavigationReadMore() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
ReadMorePage pageReadMore = PageFactory.initElements(context.getDriver(), ReadMorePage.class);
pageMain.clickReadMore();
Assertions.assertTrue(pageReadMore.isReadMorePresent());
}
@Test
public void testNavigationSocialLink() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
pageMain.clickSocialLink();
}
@Test
public void testReviews() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
ReviewsPage pageReviews = PageFactory.initElements(context.getDriver(), ReviewsPage.class);
pageMain.clickReviews();
Assertions.assertTrue(pageReviews.areReviewsPresent());
}
@Test
public void testSideMenu() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class);
SideMenuPage pageSideBar = PageFactory.initElements(context.getDriver(), SideMenuPage.class);
pageMain.clickMainMenu();
pageMainMenu.clickTV();
Assertions.assertTrue(pageSideBar.isSideBarPresent());
}
@Test
public void testProductMenu() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
MainMenuPage pageMainMenu = PageFactory.initElements(context.getDriver(), MainMenuPage.class);
SideMenuPage pageSideMenu = PageFactory.initElements(context.getDriver(), SideMenuPage.class);
ProductPage pageProduct = PageFactory.initElements(context.getDriver(), ProductPage.class);
pageMain.clickMainMenu();
pageMainMenu.clickTV();
pageSideMenu.clickProduct();
pageProduct.clickProductMenu();
Assertions.assertTrue(pageProduct.isProductMenuPresent());
}
}

View File

@ -0,0 +1,67 @@
import context.ChromeContext;
import context.Context;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.support.PageFactory;
import page.*;
public class ProductsTest {
private final static String APP_URL_MVideo = "https://www.mvideo.ru/";
private static Context context;
@BeforeAll
public static void setup() {
context = new ChromeContext();
context.start();
context.getDriver().manage().window().setSize(new Dimension(1366, 768));
}
@AfterAll
public static void quit() {
context.close();
}
@Test
public void testBasketIcon() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
BasketPage pageBasket = PageFactory.initElements(context.getDriver(), BasketPage.class);
pageMain.clickBasketIcon();
Assertions.assertTrue(pageBasket.isBasketPagePresent());
}
@Test
public void testDeleteFromBaster() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
BasketPage pageBasket = PageFactory.initElements(context.getDriver(), BasketPage.class);
pageMain.clickBasketIcon();
pageBasket.clickDeleteSpan();
Assertions.assertTrue(pageBasket.isBasketPagePresent());
}
@Test
public void testOrder() {
context.getDriver().get(APP_URL_MVideo);
MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
BasketPage pageBasket = PageFactory.initElements(context.getDriver(), BasketPage.class);
AuthPage pageAuth = PageFactory.initElements(context.getDriver(), AuthPage.class);
OrderPage pageOrder = PageFactory.initElements(context.getDriver(), OrderPage.class);
String inputStringMail = "test543321@mail.ru";
String inputStringPhone = "9603785796";
String inputStringName = "Антон";
pageMain.clickBasketIcon();
pageBasket.clickOrder();
pageAuth.clickSubmitBtnAuth();
pageOrder.setInputStringsAuth(inputStringMail, inputStringPhone, inputStringName);
pageOrder.clickMakeOrderBtn();
Assertions.assertTrue(pageOrder.isOrderPresent());
}
}

View File

@ -1,6 +1,7 @@
package context;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class ChromeContext extends Context {
private final static String WINDOWS_DRIVER = "chromedriver.exe";
@ -9,6 +10,8 @@ public class ChromeContext extends Context {
@Override
protected void createDriver() {
// ChromeOptions options = new ChromeOptions();
// options.addArguments("--start-maximazed");
driver = new ChromeDriver();
}

View File

@ -0,0 +1,40 @@
package page;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class AuthPage {
WebDriver driver;
@FindBy(id = "frm-email")
private WebElement fieldEmail;
@FindBy(id = "frm-password")
private WebElement fieldPass;
@FindBy(id = "submit-button")
private WebElement submitBtn;
@FindBy(xpath = "//*[@id=\"purchaseGuestForm\"]/input[7]")
private WebElement submitBtnAuth;
public AuthPage(WebDriver driver) {
this.driver = driver;
}
public AuthPage setInputStrings(String textMail, String textPass) {
fieldEmail.sendKeys(textMail);
fieldPass.sendKeys(textPass);
return this;
}
public void clickSubmitButton() {
submitBtn.sendKeys(Keys.RETURN);
}
public void clickSubmitBtnAuth() {
submitBtnAuth.sendKeys(Keys.RETURN);
}
}

View File

@ -0,0 +1,37 @@
package page;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class BasketPage {
WebDriver driver;
public BasketPage(WebDriver driver) {
this.driver = driver;
}
@FindBy(css = ".c-logo")
private WebElement logoIcon;
@FindBy(css = ".c-cart-item__delete .c-link")
private WebElement deleteSpan;
@FindBy(css = ".c-btn_full-size")
private WebElement makeOrderBtn;
public boolean isBasketPagePresent() { return driver.getTitle().contains("Корзина"); }
public void clickLogo() {
logoIcon.sendKeys(Keys.RETURN);
}
public void clickDeleteSpan() {
deleteSpan.sendKeys(Keys.RETURN);
}
public void clickOrder() {
makeOrderBtn.sendKeys(Keys.RETURN);
}
}

View File

@ -0,0 +1,13 @@
package page;
import org.openqa.selenium.WebDriver;
public class FacebookPage {
WebDriver driver;
public FacebookPage(WebDriver driver) {
this.driver = driver;
}
public boolean isSocialLinkPresent() { return driver.getTitle().contains("Facebook"); }
}

View File

@ -0,0 +1,16 @@
package page;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class FooterMenuPage {
WebDriver driver;
public FooterMenuPage(WebDriver driver) {
this.driver = driver;
}
public boolean isFooterMenuPresent() {
return driver.findElement(By.cssSelector(".lazy-load-image-holder")).isDisplayed();
}
}

View File

@ -0,0 +1,23 @@
package page;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import java.util.List;
public class MainMenuPage {
WebDriver driver;
@FindBy(css =".sidebar-category a")
private List<WebElement> TVs;
public MainMenuPage(WebDriver driver) {
this.driver = driver;
}
public boolean isMainMenuPresent() { return driver.getTitle().contains("Телевизоры, Аудио-видео, Hi-Fi"); }
public void clickTV() { TVs.get(0).sendKeys(Keys.RETURN); }
}

View File

@ -0,0 +1,127 @@
package page;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import java.util.List;
public class MainPage {
WebDriver driver;
@FindBy(css = ".header-nav-item-link")
private List<WebElement> mainMenu;
@FindBy(xpath = "/html/body/div[1]/div/div[2]/div/div[1]/div[7]/nav/ul/li[8]/div/div/ul[2]/li[1]/ul/li[1]/a")
private WebElement subMenu;
@FindBy(css = ".footer-nav-link")
private List<WebElement> footerMenu;
@FindBy(css = ".header-logo")
private WebElement mVideoLogo;
@FindBy(css = ".shop-service-list .view-all-base")
private List<WebElement> readMore;
@FindBy(css = ".socials-link")
private List<WebElement> socialLink;
@FindBy(css = ".promo-banner-slider-info .btn")
private WebElement reviews;
@FindBy(css = ".header-search-input")
private WebElement inputField;
@FindBy(css = ".header-login-option-link")
private List<WebElement> authReg;
@FindBy(xpath = ".//*[@id=\"js-form-submit-id\"]")
private WebElement basketIcon;
@FindBy(id = "frm-subscr-email-address")
private WebElement inputEMail;
@FindBy(id = "submitSubscribe")
private WebElement sbmtSubBtn;
public MainPage(WebDriver driver) {
this.driver = driver;
}
public boolean isLogoPresent() { return driver.findElement(By.cssSelector(".header-logo")).isDisplayed(); }
public boolean isAccountPresent() {
return driver.findElement(By.cssSelector(".my-account-personal-photo-placeholder")).isDisplayed();
}
public boolean isSubSuccess() { return driver.findElement(By.cssSelector(".text-success")).isDisplayed(); }
public void clickMainMenu() {
mainMenu.get(1).sendKeys(Keys.RETURN);
}
public void clickSubMenu() {
Actions builder = new Actions(driver);
builder.moveToElement(mainMenu.get(7)).perform();
subMenu.sendKeys(Keys.RETURN);
}
public void clickFooterMenu() {
footerMenu.get(1).sendKeys(Keys.RETURN);
}
public void clickLogo() {
mVideoLogo.sendKeys(Keys.RETURN);
}
public void clickReadMore() {
readMore.get(1).sendKeys(Keys.RETURN);
}
public void clickSocialLink() {
String base = driver.getWindowHandle();
socialLink.get(0).sendKeys(Keys.RETURN);
driver.switchTo().window(base);
}
public void clickReviews() {
reviews.sendKeys(Keys.RETURN);
}
public MainPage setSearchString(String text) {
inputField.sendKeys(text);
return this;
}
public void clickSubmitButton() {
inputField.sendKeys(Keys.RETURN);
}
public void clickAuth() {
authReg.get(0).sendKeys(Keys.RETURN);
}
public void clickReg() {
authReg.get(1).sendKeys(Keys.RETURN);
}
public void clickBasketIcon() {
basketIcon.sendKeys(Keys.RETURN);
}
public MainPage setEmail(String eMailText) {
inputEMail.sendKeys(eMailText);
return this;
}
public void clickSubmitSub() {
sbmtSubBtn.sendKeys(Keys.RETURN);
}
}

View File

@ -0,0 +1,46 @@
package page;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class OrderPage {
WebDriver driver;
@FindBy(id = "field_8")
private WebElement fieldEmailAuth;
@FindBy(id = "myPhone")
private WebElement fieldPhoneAuth;
@FindBy(id = "field_6")
private WebElement fieldNameAuth;
@FindBy(xpath = "/html/body/div[1]/div[2]/div[3]/div[2]/div/form/input[9]")
private WebElement makeOrderBtn;
@FindBy(css = ".c-logo")
private WebElement logo;
public OrderPage(WebDriver driver) {
this.driver = driver;
}
public boolean isOrderPresent() { return driver.getTitle().contains("Информация о заказе"); }
public OrderPage setInputStringsAuth(String textMail, String textPhone, String textName) {
fieldEmailAuth.sendKeys(textMail);
fieldPhoneAuth.sendKeys(textPhone);
fieldNameAuth.sendKeys(textName);
return this;
}
public void clickMakeOrderBtn() {
makeOrderBtn.sendKeys(Keys.RETURN);
}
public void clickLogo() {
logo.sendKeys(Keys.RETURN);
}
}

View File

@ -0,0 +1,61 @@
package page;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import java.util.List;
public class ProductPage {
WebDriver driver;
@FindBy(css = ".c-tabs__menu .c-tabs__menu-link")
private List<WebElement> productMenu;
@FindBy(css = ".c-checkbox__icon")
private WebElement favoriteSpan;
@FindBy(css = ".product-leave-review-btn")
private WebElement leaveReviewBtn;
@FindBy(id = "userEmail")
private WebElement inputUserName;
@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 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);
}
public void clickFavorite() { favoriteSpan.sendKeys(Keys.RETURN); }
public void clickLeaveReviewBtn() { leaveReviewBtn.sendKeys(Keys.RETURN); }
public ProductPage setReviewData(String eMailText, String reviewText) {
inputUserName.sendKeys(eMailText);
inputReviewText.sendKeys(reviewText);
return this;
}
}

View File

@ -0,0 +1,13 @@
package page;
import org.openqa.selenium.WebDriver;
public class ReadMorePage {
WebDriver driver;
public ReadMorePage(WebDriver driver) {
this.driver = driver;
}
public boolean isReadMorePresent() { return driver.getTitle().contains("Быстросервис"); }
}

View File

@ -0,0 +1,46 @@
package page;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class RegPage {
WebDriver driver;
@FindBy(id = "register-form-name-input")
private WebElement inputName;
@FindBy(id = "register-form-phone")
private WebElement inputPhone;
@FindBy(id = "register-register-form-email-phone")
private WebElement inputEmail;
@FindBy(id = "register-form-password")
private WebElement inputPass;
@FindBy(id = "register-form-confirm-password")
private WebElement inputPassConfirm;
@FindBy(css = ".add-address-submit-btn")
private WebElement submitBtn;
public RegPage(WebDriver driver) {
this.driver = driver;
}
public RegPage setInputStrings(String textName, String textPhone, String textEmail, String textPass,
String textPassConfirm) {
inputName.sendKeys(textName);
inputPhone.sendKeys(textPhone);
inputEmail.sendKeys(textEmail);
inputPass.sendKeys(textPass);
inputPassConfirm.sendKeys(textPassConfirm);
return this;
}
public void clickSubmitBtn() {
submitBtn.sendKeys(Keys.RETURN);
}
}

View File

@ -0,0 +1,13 @@
package page;
import org.openqa.selenium.WebDriver;
public class ReviewsPage {
WebDriver driver;
public ReviewsPage(WebDriver driver) {
this.driver = driver;
}
public boolean areReviewsPresent() { return driver.getTitle().contains("отзывы покупателей"); }
}

View File

@ -1,38 +0,0 @@
package page;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class SearchPage {
WebDriver driver;
@FindBy(css = "input.header-search-input")
private WebElement inputField;
@FindBy(xpath = "//*[@class='menu border']/a[7]")
private WebElement usersLink;
public SearchPage(WebDriver driver) {
this.driver = driver;
}
public SearchPage setSearchString(String text) {
inputField.sendKeys(text);
return this;
}
public void clickSubmitButton() {
inputField.sendKeys(Keys.RETURN);
}
public void clickUsersLink() {
usersLink.click();
}
public boolean isUserPresent() {
return driver.findElement(By.cssSelector(".user-list-info")).isDisplayed();
}
}

View File

@ -0,0 +1,96 @@
package page;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import java.util.List;
public class SideMenuPage {
WebDriver driver;
@FindBy(css = ".c-product-tile .sel-product-tile-title")
private List<WebElement> product;
@FindBy(css = ".header-logo")
private WebElement mVideoLogo;
@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;
@FindBy(css = ".o-plp-container_sub-header .select-button")
private WebElement selectBtn;
@FindBy(css = ".drop-box a")
private List<WebElement> attribute;
@FindBy(css = ".c-text-field .facet-price-min")
private WebElement priceLeft;
@FindBy(css = ".c-text-field .facet-price-max")
private WebElement priceRight;
public SideMenuPage(WebDriver driver) {
this.driver = driver;
}
public boolean isSideBarPresent() {
return driver.findElement(By.cssSelector(".c-plp-facets__item-link")).isDisplayed();
}
public boolean isProductContainsPoint() {
return driver.findElement(By.cssSelector(".c-product-tile__description")).isDisplayed();
}
public void clickProduct() {
product.get(0).sendKeys(Keys.RETURN);
}
public void clickLogo() {
mVideoLogo.sendKeys(Keys.RETURN);
}
public void clickCategoryPoint(int point) { categoryPoints.get(point).sendKeys(Keys.RETURN); }
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++) {
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);
}
}
public void clickClearBtn() { clearBtn.sendKeys(Keys.RETURN); }
public void selectAttribute() {
selectBtn.sendKeys(Keys.RETURN);
attribute.get(3).sendKeys(Keys.RETURN);
}
public SideMenuPage setPrice(String minPrice, String maxPrice) {
priceLeft.clear();
priceLeft.sendKeys(minPrice);
priceRight.sendKeys(Keys.RETURN);
priceRight.clear();
priceRight.sendKeys(maxPrice);
priceRight.sendKeys(Keys.RETURN);
return this;
}
}

View File

@ -0,0 +1,13 @@
package page;
import org.openqa.selenium.WebDriver;
public class SubMenuPage {
WebDriver driver;
public SubMenuPage(WebDriver driver) {
this.driver = driver;
}
public boolean isSubMenuPresent() { return driver.getTitle().contains("Фены и фен-щетки"); }
}