Vasin #3

Closed
mrHewd11 wants to merge 5 commits from Vasin into master
19 changed files with 406 additions and 66 deletions
Showing only changes of commit af20c87fdc - Show all commits

View File

@ -18,7 +18,7 @@ public class AccountTest {
public static void setup() {
context = new ChromeContext();
context.start();
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
context.getDriver().manage().window().setSize(new Dimension(1366, 768));
}
@AfterAll

View File

@ -0,0 +1,59 @@
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 testFollow() {
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());
}
@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);
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());
pageMain.clickLogo();
}
}

View File

@ -24,7 +24,7 @@ public class FiltersTest {
public static void setup() {
context = new ChromeContext();
context.start();
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
context.getDriver().manage().window().setSize(new Dimension(1366, 768));
}
@AfterAll
@ -131,6 +131,52 @@ public class FiltersTest {
pageFilter.clickLogo();
}
@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());
pageMain.clickLogo();
}
@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());
pageMain.clickLogo();
}
@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());
// pageMain.clickLogo();
}
@Test
public void testClearCriteria() {
context.getDriver().get(APP_URL_MVideo);

View File

@ -17,7 +17,7 @@ public class NavigationTest {
public static void setup() {
context = new ChromeContext();
context.start();
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
context.getDriver().manage().window().setSize(new Dimension(1366, 768));
}
@AfterAll

View File

@ -0,0 +1,71 @@
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());
pageBasket.clickLogo();
}
@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());
pageBasket.clickLogo();
}
@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());
pageOrder.clickLogo();
}
}

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

@ -1,15 +1,10 @@
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;
import java.util.Set;
public class AuthPage {
WebDriver driver;
@ -22,6 +17,9 @@ public class AuthPage {
@FindBy(id = "submit-button")
private WebElement submitBtn;
@FindBy(xpath = "//*[@id=\"purchaseGuestForm\"]/input[7]")
private WebElement submitBtnAuth;
public AuthPage(WebDriver driver) {
this.driver = driver;
}
@ -35,4 +33,8 @@ public class AuthPage {
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

@ -1,14 +1,6 @@
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;
import java.util.Set;
public class FacebookPage {
WebDriver driver;

View File

@ -1,14 +1,7 @@
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;
import java.util.Set;
public class FooterMenuPage {
WebDriver driver;
@ -17,5 +10,7 @@ public class FooterMenuPage {
this.driver = driver;
}
public boolean isFooterMenuPresent() { return driver.findElement(By.cssSelector(".lazy-load-image-holder")).isDisplayed(); }
public boolean isFooterMenuPresent() {
return driver.findElement(By.cssSelector(".lazy-load-image-holder")).isDisplayed();
}
}

View File

@ -1,14 +1,11 @@
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;
import java.util.Set;
public class MainMenuPage {
WebDriver driver;

View File

@ -8,7 +8,6 @@ import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import java.util.List;
import java.util.Set;
public class MainPage {
WebDriver driver;
@ -32,7 +31,7 @@ public class MainPage {
private List<WebElement> socialLink;
@FindBy(css = ".promo-banner-slider-info .btn")
private List<WebElement> reviews;
private WebElement reviews;
@FindBy(css = ".header-search-input")
private WebElement inputField;
@ -40,6 +39,14 @@ public class MainPage {
@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;
@ -47,7 +54,11 @@ public class MainPage {
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 isAccountPresent() {
return driver.findElement(By.cssSelector(".my-account-personal-photo-placeholder")).isDisplayed();
}
public boolean isFollowSuccess() { return driver.findElement(By.cssSelector(".text-success")).isDisplayed(); }
public void clickMainMenu() {
mainMenu.get(1).sendKeys(Keys.RETURN);
@ -81,7 +92,7 @@ public class MainPage {
}
public void clickReviews() {
reviews.get(0).sendKeys(Keys.RETURN);
reviews.sendKeys(Keys.RETURN);
}
public MainPage setSearchString(String text) {
@ -96,4 +107,17 @@ public class MainPage {
public void clickAuth() {
authReg.get(0).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

@ -4,11 +4,9 @@ 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;
import java.util.Set;
public class ProductPage {
WebDriver driver;
@ -16,15 +14,37 @@ public class ProductPage {
@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;
public ProductPage(WebDriver 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 void clickProductMenu() {
productMenu.get(1).sendKeys(Keys.RETURN);
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

@ -1,14 +1,6 @@
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;
import java.util.Set;
public class ReadMorePage {
WebDriver driver;

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

@ -1,14 +1,6 @@
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;
import java.util.Set;
public class ReviewsPage {
WebDriver driver;

View File

@ -4,12 +4,9 @@ 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 javax.annotation.CheckForNull;
import java.util.List;
import java.util.Set;
public class SideMenuPage {
WebDriver driver;
@ -26,13 +23,29 @@ public class SideMenuPage {
@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 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 boolean isProductContainsPoint() {
return driver.findElement(By.cssSelector(".c-product-tile__description")).isDisplayed();
}
public void clickProduct() {
product.get(0).sendKeys(Keys.RETURN);
@ -50,7 +63,20 @@ public class SideMenuPage {
}
}
public void clickClearBtn() {
clearBtn.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

@ -1,14 +1,6 @@
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;
import java.util.Set;
public class SubMenuPage {
WebDriver driver;