diff --git a/Vasin/.gitignore b/Vasin/.gitignore deleted file mode 100644 index 3bac491..0000000 --- a/Vasin/.gitignore +++ /dev/null @@ -1,156 +0,0 @@ - -# Created by https://www.gitignore.io/api/intellij,java,maven,gradle,eclipse,netbeans - -### Intellij ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm - -*.iml -nb-configuration.xml - -## Directory-based project format: -.idea/ -.target -# if you remove the above rule, at least ignore the following: - -# User-specific stuff: -# .idea/workspace.xml -# .idea/tasks.xml -# .idea/dictionaries -# .idea/shelf - -# Sensitive or high-churn files: -# .idea/dataSources.ids -# .idea/dataSources.xml -# .idea/sqlDataSources.xml -# .idea/dynamic.xml -# .idea/uiDesigner.xml - -# Gradle: -# .idea/gradle.xml -# .idea/libraries - -# Mongo Explorer plugin: -# .idea/mongoSettings.xml - -## File-based project format: -*.ipr -*.iws - -## Plugin-specific files: - -# IntelliJ -/out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - - -### Java ### -*.class - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - - -### Maven ### -target/ -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties - - -### Gradle ### -.gradle -build/ - -# Ignore Gradle GUI config -gradle-app.setting - -# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) -!gradle-wrapper.jar - -# Cache of project -.gradletasknamecache - - -### Eclipse ### - -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath - -# Eclipse Core -.project - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# PyDev specific (Python IDE for Eclipse) -*.pydevproject - -# CDT-specific (C/C++ Development Tooling) -.cproject - -# JDT-specific (Eclipse Java Development Tools) -.classpath - -# Java annotation processor (APT) -.factorypath - -# PDT-specific (PHP Development Tools) -.buildpath - -# sbteclipse plugin -.target - -# TeXlipse plugin -.texlipse - -# STS (Spring Tool Suite) -.springBeans - - -### NetBeans ### -nbproject/private/ -build/ -nbbuild/ -dist/ -nbdist/ -nbactions.xml -.nb-gradle/ - -*.log - -csv/ \ No newline at end of file diff --git a/Vasin/.gitkeep b/Vasin/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Vasin/README.md b/Vasin/README.md deleted file mode 100644 index 635e81b..0000000 --- a/Vasin/README.md +++ /dev/null @@ -1,2 +0,0 @@ -Selenium WebDriver example project - diff --git a/Vasin/pom.xml b/Vasin/pom.xml deleted file mode 100644 index 756ca36..0000000 --- a/Vasin/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - 4.0.0 - tis-2017 - tis-2017 - 1.0 - - UTF-8 - 1.8 - 1.8 - - - - - org.seleniumhq.selenium - selenium-java - 3.6.0 - - - org.junit.jupiter - junit-jupiter-api - 5.1.0-RC1 - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - true - - true - lib/ - ru.ulstu.tis.Main - - - lib/ - - - - - - - \ No newline at end of file diff --git a/Vasin/src/main/java/ru/ulstu/tis/Main.java b/Vasin/src/main/java/ru/ulstu/tis/Main.java deleted file mode 100644 index 60b5db8..0000000 --- a/Vasin/src/main/java/ru/ulstu/tis/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package ru.ulstu.tis; - -public class Main { - - public static void main(String[] args) { - } -} diff --git a/Vasin/src/main/resources/drivers/chromedriver b/Vasin/src/main/resources/drivers/chromedriver deleted file mode 100644 index 02ff671..0000000 Binary files a/Vasin/src/main/resources/drivers/chromedriver and /dev/null differ diff --git a/Vasin/src/main/resources/drivers/chromedriver.exe b/Vasin/src/main/resources/drivers/chromedriver.exe deleted file mode 100644 index 28a4067..0000000 Binary files a/Vasin/src/main/resources/drivers/chromedriver.exe and /dev/null differ diff --git a/Vasin/src/main/resources/drivers/geckodriver b/Vasin/src/main/resources/drivers/geckodriver deleted file mode 100644 index ba1da8c..0000000 Binary files a/Vasin/src/main/resources/drivers/geckodriver and /dev/null differ diff --git a/Vasin/src/main/resources/drivers/geckodriver.exe b/Vasin/src/main/resources/drivers/geckodriver.exe deleted file mode 100644 index 6208aa8..0000000 Binary files a/Vasin/src/main/resources/drivers/geckodriver.exe and /dev/null differ diff --git a/Vasin/src/test/java/GithubUserSearch.java b/Vasin/src/test/java/GithubUserSearch.java deleted file mode 100644 index 93ad2dd..0000000 --- a/Vasin/src/test/java/GithubUserSearch.java +++ /dev/null @@ -1,41 +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()); - } -} \ No newline at end of file diff --git a/Vasin/src/test/java/NavigationTest.java b/Vasin/src/test/java/NavigationTest.java deleted file mode 100644 index 48a1967..0000000 --- a/Vasin/src/test/java/NavigationTest.java +++ /dev/null @@ -1,82 +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 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(1600, 900)); - } - - @AfterAll - public static void quit() { - - context.close(); - } - - @Test - public void testLogo() { - context.getDriver().get(APP_URL_MVideo); - SearchPage page = PageFactory.initElements(context.getDriver(), SearchPage.class); - - page.clickLogo(); - } - - @Test - public void testNavigationMainMenu() { - context.getDriver().get(APP_URL_MVideo); - SearchPage page = PageFactory.initElements(context.getDriver(), SearchPage.class); - - page.clickMainMenu(); - page.clickLogo(); - } - - //not visible - @Test - public void testNavigationSubMenu() { - context.getDriver().get(APP_URL_MVideo); - SearchPage page = PageFactory.initElements(context.getDriver(), SearchPage.class); - - page.clickSubMenu(); - page.clickLogo(); - } - - @Test - public void testNavigationFooterMenu() { - context.getDriver().get(APP_URL_MVideo); - SearchPage page = PageFactory.initElements(context.getDriver(), SearchPage.class); - - page.clickFooterMenu(); - page.clickLogo(); - } - - @Test - public void testNavigationReadMore() { - context.getDriver().get(APP_URL_MVideo); - SearchPage page = PageFactory.initElements(context.getDriver(), SearchPage.class); - - page.clickReadMore(); - page.clickLogo(); - } - - @Test - public void testNavigationSocialLink() { - context.getDriver().get(APP_URL_MVideo); - SearchPage page = PageFactory.initElements(context.getDriver(), SearchPage.class); - - page.clickSocialLink(); - page.clickLogo(); - } -} diff --git a/Vasin/src/test/java/context/ChromeContext.java b/Vasin/src/test/java/context/ChromeContext.java deleted file mode 100644 index 05d9cde..0000000 --- a/Vasin/src/test/java/context/ChromeContext.java +++ /dev/null @@ -1,24 +0,0 @@ -package context; - -import org.openqa.selenium.chrome.ChromeDriver; - -public class ChromeContext extends Context { - private final static String WINDOWS_DRIVER = "chromedriver.exe"; - private final static String LINUX_DRIVER = "chromedriver"; - private final static String DRIVER_TYPE = "webdriver.chrome.driver"; - - @Override - protected void createDriver() { - driver = new ChromeDriver(); - } - - @Override - protected String getDriverExecutable(boolean isWindows) { - return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER; - } - - @Override - protected String getDriverType() { - return DRIVER_TYPE; - } -} diff --git a/Vasin/src/test/java/context/Context.java b/Vasin/src/test/java/context/Context.java deleted file mode 100644 index 928d5dd..0000000 --- a/Vasin/src/test/java/context/Context.java +++ /dev/null @@ -1,43 +0,0 @@ -package context; - -import org.openqa.selenium.WebDriver; - -import java.util.concurrent.TimeUnit; - -public abstract class Context { - private final static String DRIVER_LOCATION = "drivers/%s"; - protected WebDriver driver; - - public WebDriver getDriver() { - if (driver != null) { - return driver; - } - throw new IllegalStateException("WebDriver is not initialized"); - } - - public void start() { - System.setProperty(getDriverType(), getDriverExecutablePath()); - createDriver(); - // это плохая инструкция для автотестов, т.к. лучше задавать для конкретного элемента или кейса - driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); - } - - public void close() { - driver.quit(); - } - - protected abstract void createDriver(); - - protected abstract String getDriverType(); - - protected abstract String getDriverExecutable(boolean windows); - - private String getDriverExecutablePath() { - return Context.class.getClassLoader().getResource( - String.format(DRIVER_LOCATION, getDriverExecutable(isWindows()))).getFile(); - } - - private boolean isWindows() { - return System.getProperty("os.name").toLowerCase().contains("windows"); - } -} diff --git a/Vasin/src/test/java/context/FirefoxContext.java b/Vasin/src/test/java/context/FirefoxContext.java deleted file mode 100644 index 1d5c163..0000000 --- a/Vasin/src/test/java/context/FirefoxContext.java +++ /dev/null @@ -1,24 +0,0 @@ -package context; - -import org.openqa.selenium.firefox.FirefoxDriver; - -public class FirefoxContext extends Context { - private final static String WINDOWS_DRIVER = "geckodriver.exe"; - private final static String LINUX_DRIVER = "geckodriver"; - private final static String DRIVER_TYPE = "webdriver.gecko.driver"; - - @Override - protected void createDriver() { - driver = new FirefoxDriver(); - } - - @Override - protected String getDriverExecutable(boolean isWindows) { - return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER; - } - - @Override - protected String getDriverType() { - return DRIVER_TYPE; - } -} diff --git a/Vasin/src/test/java/Filters.java b/src/test/java/AccountTest.java similarity index 56% rename from Vasin/src/test/java/Filters.java rename to src/test/java/AccountTest.java index 8622f6f..f03da6b 100644 --- a/Vasin/src/test/java/Filters.java +++ b/src/test/java/AccountTest.java @@ -6,9 +6,10 @@ 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; +import page.AuthPage; +import page.MainPage; -public class Filters { +public class AccountTest { private final static String APP_URL_MVideo = "https://www.mvideo.ru/"; private static Context context; @@ -27,13 +28,16 @@ public class Filters { } @Test - public void testSearch() { + public void testAuth() { context.getDriver().get(APP_URL_MVideo); - String searchString = "телевизор samsung"; + String inputStringMail = "test543321@mail.ru"; + String inputStringPassword = "1234qwerQWER"; - SearchPage page = PageFactory.initElements(context.getDriver(), SearchPage.class); - page.setSearchString(searchString); - page.clickSubmitButton(); - page.clickLogo(); + 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()); } } diff --git a/src/test/java/FiltersTest.java b/src/test/java/FiltersTest.java new file mode 100644 index 0000000..4988d24 --- /dev/null +++ b/src/test/java/FiltersTest.java @@ -0,0 +1,153 @@ +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 point = new ArrayList(); + + @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 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.isProductPresent()); + pageMain.clickLogo(); + } + + @Test + public void testProductOneCategoryOnePoint() { + 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.clickPoint(5); + Assertions.assertTrue(pageFilter.isProductContainsPoint()); + pageFilter.clickLogo(); + } + + @Test + public void testProductOneCategoryTwoPoints() { + 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(); + point.clear(); + point.add(5); + point.add(6); + pageFilter.clickPoints(point); + Assertions.assertTrue(pageFilter.isProductContainsPoint()); + pageFilter.clickLogo(); + } + + @Test + public void testProductTwoCategoryOnePoint() { + 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(); + point.clear(); + point.add(3); + point.add(6); + pageFilter.clickPoints(point); + Assertions.assertTrue(pageFilter.isProductContainsPoint()); + pageFilter.clickLogo(); + } + + @Test + public void testProductTwoCategoryTwoPoints() { + 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(); + point.clear(); + point.add(3); + point.add(4); + point.add(6); + point.add(7); + pageFilter.clickPoints(point); + Assertions.assertTrue(pageFilter.isProductContainsPoint()); + pageFilter.clickLogo(); + } + + @Test + public void testProductCombine() { + 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(); + point.clear(); + point.add(3); + point.add(6); + point.add(4); + pageFilter.clickPoints(point); + Assertions.assertTrue(pageFilter.isProductContainsPoint()); + pageFilter.clickLogo(); + } + + @Test + public void testClearCriteria() { + 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(); + point.clear(); + point.add(3); + point.add(4); + point.add(6); + point.add(7); + pageFilter.clickPoints(point); + pageFilter.clickClearBtn(); + Assertions.assertTrue(pageFilter.isProductContainsPoint()); + pageFilter.clickLogo(); + } +} diff --git a/src/test/java/GithubUserSearch.java b/src/test/java/GithubUserSearch.java deleted file mode 100644 index 68e7ddd..0000000 --- a/src/test/java/GithubUserSearch.java +++ /dev/null @@ -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()); - } -} diff --git a/src/test/java/NavigationTest.java b/src/test/java/NavigationTest.java new file mode 100644 index 0000000..9c28e68 --- /dev/null +++ b/src/test/java/NavigationTest.java @@ -0,0 +1,130 @@ +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(1600, 900)); + } + + @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()); + pageMain.clickLogo(); + } + + @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()); + pageMain.clickLogo(); + } + + @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()); + pageMain.clickLogo(); + } + + @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()); + pageMain.clickLogo(); + } + + @Test + public void testNavigationSocialLink() { + context.getDriver().get(APP_URL_MVideo); + MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class); + + pageMain.clickSocialLink(); + pageMain.clickLogo(); + } + + @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()); + pageMain.clickLogo(); + } + + @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()); + pageMain.clickLogo(); + } + + @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()); + pageMain.clickLogo(); + } +} diff --git a/src/test/java/page/AuthPage.java b/src/test/java/page/AuthPage.java new file mode 100644 index 0000000..53f1478 --- /dev/null +++ b/src/test/java/page/AuthPage.java @@ -0,0 +1,38 @@ +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; + + @FindBy(id = "frm-email") + private WebElement fieldEmail; + + @FindBy(id = "frm-password") + private WebElement fieldPass; + + @FindBy(id = "submit-button") + private WebElement submitBtn; + + 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); + } +} diff --git a/src/test/java/page/FacebookPage.java b/src/test/java/page/FacebookPage.java new file mode 100644 index 0000000..248c216 --- /dev/null +++ b/src/test/java/page/FacebookPage.java @@ -0,0 +1,21 @@ +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; + + public FacebookPage(WebDriver driver) { + this.driver = driver; + } + + public boolean isSocialLinkPresent() { return driver.getTitle().contains("Facebook"); } +} diff --git a/src/test/java/page/FooterMenuPage.java b/src/test/java/page/FooterMenuPage.java new file mode 100644 index 0000000..739cd03 --- /dev/null +++ b/src/test/java/page/FooterMenuPage.java @@ -0,0 +1,21 @@ +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; + + public FooterMenuPage(WebDriver driver) { + this.driver = driver; + } + + public boolean isFooterMenuPresent() { return driver.findElement(By.cssSelector(".lazy-load-image-holder")).isDisplayed(); } +} diff --git a/src/test/java/page/MainMenuPage.java b/src/test/java/page/MainMenuPage.java new file mode 100644 index 0000000..5098030 --- /dev/null +++ b/src/test/java/page/MainMenuPage.java @@ -0,0 +1,26 @@ +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; + + @FindBy(css =".sidebar-category a") + private List 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); } +} diff --git a/Vasin/src/test/java/page/SearchPage.java b/src/test/java/page/MainPage.java similarity index 50% rename from Vasin/src/test/java/page/SearchPage.java rename to src/test/java/page/MainPage.java index 23e3e11..1a0b53f 100644 --- a/Vasin/src/test/java/page/SearchPage.java +++ b/src/test/java/page/MainPage.java @@ -10,39 +10,81 @@ import org.openqa.selenium.support.FindBy; import java.util.List; import java.util.Set; -public class SearchPage { +public class MainPage { WebDriver driver; - @FindBy(css = ".header-search-input") - private WebElement inputField; - - @FindBy(xpath = "//*[@class='menu border']/a[7]") - private WebElement usersLink; - @FindBy(css = ".header-nav-item-link") - private WebElement mainMenu; + private List mainMenu; - @FindBy(css = ".header-nav-drop-down-list-item-link") + @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 WebElement footerMenu; + private List footerMenu; @FindBy(css = ".header-logo") private WebElement mVideoLogo; - @FindBy(css = ".shop-service-item") - private WebElement readMore; + @FindBy(css = ".shop-service-list .view-all-base") + private List readMore; @FindBy(css = ".socials-link") - private WebElement socialLink; + private List socialLink; + + @FindBy(css = ".promo-banner-slider-info .btn") + private List reviews; + + @FindBy(css = ".header-search-input") + private WebElement inputField; + + @FindBy(css = ".header-login-option-link") + private List authReg; - public SearchPage(WebDriver driver) { + public MainPage(WebDriver driver) { this.driver = driver; } - public SearchPage setSearchString(String text) { + 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 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.get(0).sendKeys(Keys.RETURN); + } + + public MainPage setSearchString(String text) { inputField.sendKeys(text); return this; } @@ -51,47 +93,7 @@ public class SearchPage { inputField.sendKeys(Keys.RETURN); } - public void clickUsersLink() { - usersLink.click(); - } - - public boolean isUserPresent() { - return driver.findElement(By.cssSelector(".user-list-info")).isDisplayed(); - } - - public void clickMainMenu() { - mainMenu.sendKeys(Keys.RETURN); - } - - public void clickSubMenu() { - Actions builder = new Actions(driver); - builder.moveToElement(mainMenu).perform(); - try { - Thread.sleep(20000L); - } catch (InterruptedException e) { - e.printStackTrace(); - } - subMenu.sendKeys(Keys.RETURN); - } - - public void clickFooterMenu() { - footerMenu.sendKeys(Keys.RETURN); - } - - public void clickLogo() { - mVideoLogo.sendKeys(Keys.RETURN); - } - - public void clickReadMore() { - readMore.sendKeys(Keys.RETURN); - } - - public void clickSocialLink() { - String base = driver.getWindowHandle(); - - socialLink.sendKeys(Keys.RETURN); - - //driver.close(); - driver.switchTo().window(base); + public void clickAuth() { + authReg.get(0).sendKeys(Keys.RETURN); } } diff --git a/src/test/java/page/ProductPage.java b/src/test/java/page/ProductPage.java new file mode 100644 index 0000000..cca6125 --- /dev/null +++ b/src/test/java/page/ProductPage.java @@ -0,0 +1,30 @@ +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 ProductPage { + WebDriver driver; + + @FindBy(css = ".c-tabs__menu .c-tabs__menu-link") + private List productMenu; + + 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 void clickProductMenu() { + productMenu.get(1).sendKeys(Keys.RETURN); + } +} diff --git a/src/test/java/page/ReadMorePage.java b/src/test/java/page/ReadMorePage.java new file mode 100644 index 0000000..f499d78 --- /dev/null +++ b/src/test/java/page/ReadMorePage.java @@ -0,0 +1,21 @@ +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; + + public ReadMorePage(WebDriver driver) { + this.driver = driver; + } + + public boolean isReadMorePresent() { return driver.getTitle().contains("Быстросервис"); } +} diff --git a/src/test/java/page/ReviewsPage.java b/src/test/java/page/ReviewsPage.java new file mode 100644 index 0000000..0027e7e --- /dev/null +++ b/src/test/java/page/ReviewsPage.java @@ -0,0 +1,21 @@ +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; + + public ReviewsPage(WebDriver driver) { + this.driver = driver; + } + + public boolean areReviewsPresent() { return driver.getTitle().contains("отзывы покупателей"); } +} diff --git a/src/test/java/page/SearchPage.java b/src/test/java/page/SearchPage.java deleted file mode 100644 index 87f5b38..0000000 --- a/src/test/java/page/SearchPage.java +++ /dev/null @@ -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(); - } -} diff --git a/src/test/java/page/SideMenuPage.java b/src/test/java/page/SideMenuPage.java new file mode 100644 index 0000000..1f10084 --- /dev/null +++ b/src/test/java/page/SideMenuPage.java @@ -0,0 +1,56 @@ +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 javax.annotation.CheckForNull; +import java.util.List; +import java.util.Set; + +public class SideMenuPage { + WebDriver driver; + + @FindBy(css = ".c-product-tile .sel-product-tile-title") + private List product; + + @FindBy(css = ".header-logo") + private WebElement mVideoLogo; + + @FindBy(css = ".c-plp-facets__item-link") + private List points; + + @FindBy(css = ".c-plp-facets__clear-wrapper .c-btn") + private WebElement clearBtn; + + 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 clickPoint(int point) { points.get(point).sendKeys(Keys.RETURN); } + + public void clickPoints(List point) { + for (int i = 0; i < point.size(); i++) { + points.get(point.get(i)).sendKeys(Keys.RETURN); + } + } + + public void clickClearBtn() { + clearBtn.sendKeys(Keys.RETURN); + } +} diff --git a/src/test/java/page/SubMenuPage.java b/src/test/java/page/SubMenuPage.java new file mode 100644 index 0000000..a625f64 --- /dev/null +++ b/src/test/java/page/SubMenuPage.java @@ -0,0 +1,21 @@ +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; + + public SubMenuPage(WebDriver driver) { + this.driver = driver; + } + + public boolean isSubMenuPresent() { return driver.getTitle().contains("Фены и фен-щетки"); } +}