Added new tests

This commit is contained in:
mrHewd 2018-04-05 13:25:58 +03:00
parent c8b5fa7356
commit 224df21352
29 changed files with 609 additions and 571 deletions

156
Vasin/.gitignore vendored
View File

@ -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/

View File

View File

@ -1,2 +0,0 @@
Selenium WebDriver example project

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tis-2017</groupId>
<artifactId>tis-2017</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.1.0-RC1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<index>true</index>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>ru.ulstu.tis.Main</mainClass>
</manifest>
<manifestEntries>
<Class-Path>lib/</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,7 +0,0 @@
package ru.ulstu.tis;
public class Main {
public static void main(String[] args) {
}
}

View File

@ -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());
}
}

View File

@ -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();
}
}

View File

@ -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;
}
}

View File

@ -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");
}
}

View File

@ -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;
}
}

View File

@ -6,9 +6,10 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.openqa.selenium.Dimension; import org.openqa.selenium.Dimension;
import org.openqa.selenium.support.PageFactory; 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 final static String APP_URL_MVideo = "https://www.mvideo.ru/";
private static Context context; private static Context context;
@ -27,13 +28,16 @@ public class Filters {
} }
@Test @Test
public void testSearch() { public void testAuth() {
context.getDriver().get(APP_URL_MVideo); 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); MainPage pageMain = PageFactory.initElements(context.getDriver(), MainPage.class);
page.setSearchString(searchString); AuthPage pageAuth = PageFactory.initElements(context.getDriver(), AuthPage.class);
page.clickSubmitButton(); pageMain.clickAuth();
page.clickLogo(); pageAuth.setInputStrings(inputStringMail, inputStringPassword);
pageAuth.clickSubmitButton();
Assertions.assertTrue(pageMain.isAccountPresent());
} }
} }

View File

@ -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<Integer> point = new ArrayList<Integer>();
@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();
}
}

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,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();
}
}

View File

@ -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);
}
}

View File

@ -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"); }
}

View File

@ -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(); }
}

View File

@ -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<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

@ -10,39 +10,81 @@ import org.openqa.selenium.support.FindBy;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
public class SearchPage { public class MainPage {
WebDriver driver; 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") @FindBy(css = ".header-nav-item-link")
private WebElement mainMenu; private List<WebElement> 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; private WebElement subMenu;
@FindBy(css = ".footer-nav-link") @FindBy(css = ".footer-nav-link")
private WebElement footerMenu; private List<WebElement> footerMenu;
@FindBy(css = ".header-logo") @FindBy(css = ".header-logo")
private WebElement mVideoLogo; private WebElement mVideoLogo;
@FindBy(css = ".shop-service-item") @FindBy(css = ".shop-service-list .view-all-base")
private WebElement readMore; private List<WebElement> readMore;
@FindBy(css = ".socials-link") @FindBy(css = ".socials-link")
private WebElement socialLink; private List<WebElement> socialLink;
@FindBy(css = ".promo-banner-slider-info .btn")
private List<WebElement> reviews;
@FindBy(css = ".header-search-input")
private WebElement inputField;
@FindBy(css = ".header-login-option-link")
private List<WebElement> authReg;
public SearchPage(WebDriver driver) { public MainPage(WebDriver driver) {
this.driver = 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); inputField.sendKeys(text);
return this; return this;
} }
@ -51,47 +93,7 @@ public class SearchPage {
inputField.sendKeys(Keys.RETURN); inputField.sendKeys(Keys.RETURN);
} }
public void clickUsersLink() { public void clickAuth() {
usersLink.click(); authReg.get(0).sendKeys(Keys.RETURN);
}
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);
} }
} }

View File

@ -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<WebElement> 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);
}
}

View File

@ -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("Быстросервис"); }
}

View File

@ -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("отзывы покупателей"); }
}

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,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<WebElement> product;
@FindBy(css = ".header-logo")
private WebElement mVideoLogo;
@FindBy(css = ".c-plp-facets__item-link")
private List<WebElement> 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<Integer> point) {
for (int i = 0; i < point.size(); i++) {
points.get(point.get(i)).sendKeys(Keys.RETURN);
}
}
public void clickClearBtn() {
clearBtn.sendKeys(Keys.RETURN);
}
}

View File

@ -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("Фены и фен-щетки"); }
}