Semenova #2
156
Semenova/.gitignore
vendored
Normal file
156
Semenova/.gitignore
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
|
||||
# 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/
|
2
Semenova/README.md
Normal file
2
Semenova/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
Selenium WebDriver example project
|
||||
|
41
Semenova/pom.xml
Normal file
41
Semenova/pom.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<?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>AutoTesting</groupId>
|
||||
<artifactId>AutoTesting</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>LATEST</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.twitter4j</groupId>
|
||||
<artifactId>twitter4j-core</artifactId>
|
||||
<version>4.0.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
5
Semenova/src/main/java/App.java
Normal file
5
Semenova/src/main/java/App.java
Normal file
@ -0,0 +1,5 @@
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
BIN
Semenova/src/main/resources/drivers/chromedriver
Normal file
BIN
Semenova/src/main/resources/drivers/chromedriver
Normal file
Binary file not shown.
BIN
Semenova/src/main/resources/drivers/chromedriver.exe
Normal file
BIN
Semenova/src/main/resources/drivers/chromedriver.exe
Normal file
Binary file not shown.
56
Semenova/src/test/java/CalculatorTest.java
Normal file
56
Semenova/src/test/java/CalculatorTest.java
Normal file
@ -0,0 +1,56 @@
|
||||
import PageHelpers.CalculatorPageHelper;
|
||||
import Pages.CalculatorPage;
|
||||
import context.ChromeContext;
|
||||
import context.Context;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.Dimension;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
|
||||
public class CalculatorTest {
|
||||
|
||||
private final static String APP_URL = "http://www.gazprom.ru/investors/stock/investor-tools/calc/";
|
||||
private static Logger log = Logger.getLogger(CalculatorTest.class.getName());
|
||||
private static Context context;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
context = new ChromeContext();
|
||||
context.start();
|
||||
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
|
||||
|
||||
context.getDriver().get(APP_URL);
|
||||
}
|
||||
|
||||
@After
|
||||
public void quit() {
|
||||
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void countInvestor() throws InterruptedException, NoSuchMethodException {
|
||||
log.logp(INFO, getClass().getName(), "countInvestor", "Investor's count test");
|
||||
|
||||
CalculatorPage calculatorPage = PageFactory.initElements(context.getDriver(), CalculatorPage.class);
|
||||
calculatorPage.switchToCalcFrame();
|
||||
|
||||
CalculatorPageHelper calculatorPageHelper = new CalculatorPageHelper(calculatorPage);
|
||||
|
||||
calculatorPageHelper.waitAndInsertFromDate("30.09.2011");
|
||||
calculatorPageHelper.waitAndInsertToDate("01.02.2018");
|
||||
calculatorPageHelper.waitAndInsertAmount("1");
|
||||
|
||||
calculatorPage.clickCalcBtn();
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
Assert.assertTrue(calculatorPageHelper.isCalculationRight());
|
||||
}
|
||||
}
|
95
Semenova/src/test/java/DocumentTests.java
Normal file
95
Semenova/src/test/java/DocumentTests.java
Normal file
@ -0,0 +1,95 @@
|
||||
import Pages.ForShareholders;
|
||||
import Pages.JournalsPage;
|
||||
import Pages.MainPage;
|
||||
import Pages.PressPage;
|
||||
import context.ChromeContext;
|
||||
import context.Context;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.Dimension;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
|
||||
public class DocumentTests {
|
||||
|
||||
private final static String APP_URL = "http://www.gazprom.ru/";
|
||||
|
||||
private static Logger log = Logger.getLogger(DocumentTests.class.getName());
|
||||
private static Context context;
|
||||
|
||||
private String tmpPath;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
context = new ChromeContext();
|
||||
context.start();
|
||||
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
|
||||
|
||||
context.getDriver().get(APP_URL);
|
||||
|
||||
tmpPath = context.getTmpPath();
|
||||
}
|
||||
|
||||
@After
|
||||
public void quit() {
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void downloadDocs() throws InterruptedException {
|
||||
log.logp(INFO, getClass().getName(), "downloadDocs", "Downloading test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
page.clickMenuElementShareholder();
|
||||
|
||||
ForShareholders shareholdersPage = PageFactory.initElements(context.getDriver(), ForShareholders.class);
|
||||
int elementNumber = 0;
|
||||
String fileName = shareholdersPage.getFileName(elementNumber);
|
||||
shareholdersPage.clickDownloadLink(elementNumber);
|
||||
|
||||
log.logp(INFO, getClass().getName(), "downloadDocs", "Path: "+tmpPath +fileName);
|
||||
|
||||
checkDownload(fileName,100,500);
|
||||
}
|
||||
|
||||
private void checkDownload(String fileName,int timeout, int period) throws InterruptedException {
|
||||
|
||||
File f = new File(tmpPath +fileName);
|
||||
int time=0;
|
||||
while(!f.exists()&&time<timeout){
|
||||
Thread.sleep(period);
|
||||
time++;
|
||||
}
|
||||
Assert.assertTrue(f.exists());
|
||||
if(f.exists()) {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void downloadJournal() throws InterruptedException {
|
||||
log.logp(INFO, getClass().getName(), "downloadJournal", "Downloading journal test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
page.clickMenuElementPress();
|
||||
|
||||
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
||||
pressPage.clickMenuElementJournal();
|
||||
|
||||
JournalsPage journalsPage = PageFactory.initElements(context.getDriver(), JournalsPage.class);
|
||||
int elementNumber = 0;
|
||||
String fileName = journalsPage.getFileName(elementNumber);
|
||||
journalsPage.clickImgLink(elementNumber);
|
||||
|
||||
log.logp(INFO, getClass().getName(), "downloadJournal", "Path: "+tmpPath +fileName);
|
||||
|
||||
checkDownload(fileName,150,1000);
|
||||
}
|
||||
|
||||
}
|
83
Semenova/src/test/java/FeedbackTests.java
Normal file
83
Semenova/src/test/java/FeedbackTests.java
Normal file
@ -0,0 +1,83 @@
|
||||
import PageHelpers.FeedbackPageHelper;
|
||||
import Pages.*;
|
||||
import context.ChromeContext;
|
||||
import context.Context;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.Dimension;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
|
||||
public class FeedbackTests {
|
||||
|
||||
private final static String APP_URL = "http://www.gazprom.ru/";
|
||||
private static java.util.logging.Logger log = Logger.getLogger(FeedbackTests.class.getName());
|
||||
|
||||
private static Context context;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
context = new ChromeContext();
|
||||
context.start();
|
||||
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
|
||||
|
||||
context.getDriver().get(APP_URL);
|
||||
}
|
||||
|
||||
@After
|
||||
public void quit() {
|
||||
|
||||
context.close();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void offer() {
|
||||
log.logp(INFO, getClass().getName(), "offer", "Offer test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
page.clickAdditionalMenuElementPurchase();
|
||||
|
||||
PurchasesPage purchasesPage = PageFactory.initElements(context.getDriver(), PurchasesPage.class);
|
||||
purchasesPage.clickMenuItemFeedback();
|
||||
|
||||
FeedbackPage feedbackPage = PageFactory.initElements(context.getDriver(), FeedbackPage.class);
|
||||
feedbackPage.insertEmail("test@mail.ru");
|
||||
feedbackPage.insertText("test text");
|
||||
feedbackPage.submitFeedback();
|
||||
|
||||
FeedbackPageHelper helper = new FeedbackPageHelper(feedbackPage);
|
||||
|
||||
Assert.assertTrue(helper.isReceiveSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shareFunction() {
|
||||
log.logp(INFO, getClass().getName(), "shareFunction", "Sharing test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
page.clickMenuElementPress();
|
||||
|
||||
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
||||
pressPage.clickMenuElementMedia();
|
||||
|
||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||
int elementNumber = 0;
|
||||
mediaLib.clickItemImage(elementNumber);
|
||||
|
||||
mediaLib.clickSocialLinkTwitter();
|
||||
|
||||
mediaLib.switchToTwitterPopup();
|
||||
|
||||
TwitterSharingPopup twitterSharingPopup = PageFactory.initElements(context.getDriver(), TwitterSharingPopup.class);
|
||||
|
||||
Assert.assertTrue(twitterSharingPopup.isSubmitBtnPresent());
|
||||
}
|
||||
|
||||
}
|
139
Semenova/src/test/java/FilterTests.java
Normal file
139
Semenova/src/test/java/FilterTests.java
Normal file
@ -0,0 +1,139 @@
|
||||
import PageHelpers.EventsPageHelper;
|
||||
import PageHelpers.PurchasePageHelper;
|
||||
import PageHelpers.SearchResultsPageHelper;
|
||||
import PageHelpers.SubsidiariesPageHelper;
|
||||
import Pages.*;
|
||||
import context.ChromeContext;
|
||||
import context.Context;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.Dimension;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
|
||||
public class FilterTests {
|
||||
private final static String APP_URL = "http://www.gazprom.ru/";
|
||||
// private final static String APP_URL = "http://www.gazprom.ru/tenders/";
|
||||
private static java.util.logging.Logger log = Logger.getLogger(FilterTests.class.getName());
|
||||
|
||||
private static Context context;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
context = new ChromeContext();
|
||||
context.start();
|
||||
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
|
||||
|
||||
context.getDriver().get(APP_URL);
|
||||
}
|
||||
|
||||
@After
|
||||
public void quit() {
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleSearch() throws ParseException, NoSuchMethodException {
|
||||
log.logp(INFO, getClass().getName(), "simpleSearch", "Simple search test");
|
||||
|
||||
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
mainPage.clickSearchBtn();
|
||||
|
||||
String queryString = "рейтинг";
|
||||
mainPage.insertSearchText(queryString);
|
||||
mainPage.submitSearch();
|
||||
|
||||
SearchResultsPage searchResultsPage = PageFactory.initElements(context.getDriver(), SearchResultsPage.class);
|
||||
SearchResultsPageHelper helper = new SearchResultsPageHelper(searchResultsPage);
|
||||
|
||||
Assert.assertTrue(helper.searchResultsMatchQueryAndInOrder(queryString));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void sorting() throws Exception {
|
||||
log.logp(INFO, getClass().getName(), "sorting", "Sorting test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
page.clickMenuElementAbout();
|
||||
|
||||
AboutPage aboutPage = PageFactory.initElements(context.getDriver(), AboutPage.class);
|
||||
aboutPage.clickMenuElementSubsidaries();
|
||||
|
||||
SubsidiariesPage subsidiariesPage = PageFactory.initElements(context.getDriver(), SubsidiariesPage.class);
|
||||
subsidiariesPage.clickPercentFilter();
|
||||
|
||||
SubsidiariesPageHelper helper = new SubsidiariesPageHelper(subsidiariesPage);
|
||||
|
||||
Assert.assertTrue(helper.isOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filteredSearch() throws ParseException, InterruptedException, NoSuchMethodException {
|
||||
log.logp(INFO, getClass().getName(), "filteredSearch", "Filtered search test");
|
||||
|
||||
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
mainPage.clickSearchBtn();
|
||||
|
||||
String queryString = "рейтинг";
|
||||
mainPage.insertSearchText(queryString);
|
||||
mainPage.submitSearch();
|
||||
|
||||
SearchResultsPage searchResultsPage = PageFactory.initElements(context.getDriver(), SearchResultsPage.class);
|
||||
SearchResultsPageHelper helper = new SearchResultsPageHelper(searchResultsPage);
|
||||
|
||||
searchResultsPage.setFilterOn();
|
||||
searchResultsPage.selectYearByPosition(13);
|
||||
|
||||
int year = 2017;
|
||||
|
||||
Assert.assertTrue(helper.searchResultsMatchQueryYearAndInOrder(queryString,year));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void leftMenuFilter() throws ParseException {
|
||||
log.logp(INFO, getClass().getName(), "leftMenuFilter", "Filter by left menu test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
page.clickMenuElementPress();
|
||||
|
||||
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
||||
pressPage.clickMenuElementEventPage();
|
||||
|
||||
EventsPage eventsPage = PageFactory.initElements(context.getDriver(), EventsPage.class);
|
||||
eventsPage.selectYearByPosition(1);
|
||||
eventsPage.selectMonthByPosition(1);
|
||||
|
||||
int month = 1;
|
||||
|
||||
EventsPageHelper helper = new EventsPageHelper(eventsPage);
|
||||
|
||||
Assert.assertTrue(helper.eventsMatchByMonth(month));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pagination() throws InterruptedException, NoSuchMethodException {
|
||||
log.logp(INFO, getClass().getName(), "pagination", "Pagination test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
page.clickAdditionalMenuElementPurchase();
|
||||
|
||||
PurchasesPage purchasesPage = PageFactory.initElements(context.getDriver(), PurchasesPage.class);
|
||||
purchasesPage.clickMenuItemInWork();
|
||||
|
||||
int pageNumber = 1;
|
||||
purchasesPage.clickPage(pageNumber);
|
||||
|
||||
purchasesPage = PageFactory.initElements(context.getDriver(), PurchasesPage.class);
|
||||
PurchasePageHelper helper = new PurchasePageHelper(purchasesPage);
|
||||
|
||||
|
||||
Assert.assertTrue(helper.waitAndCheckPageSelection(pageNumber));
|
||||
}
|
||||
}
|
114
Semenova/src/test/java/MultimediaTests.java
Normal file
114
Semenova/src/test/java/MultimediaTests.java
Normal file
@ -0,0 +1,114 @@
|
||||
import PageHelpers.AlbumPageHelper;
|
||||
import PageHelpers.MediaLibPageHelper;
|
||||
import Pages.AlbumPage;
|
||||
import Pages.MediaLib;
|
||||
import Pages.VideoPage;
|
||||
import context.ChromeContext;
|
||||
import context.Context;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.Dimension;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
|
||||
public class MultimediaTests {
|
||||
|
||||
private final static String APP_URL = "http://www.gazprom.ru/press/media/";
|
||||
private static java.util.logging.Logger log = Logger.getLogger(MultimediaTests.class.getName());
|
||||
|
||||
private static Context context;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
context = new ChromeContext();
|
||||
context.start();
|
||||
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
|
||||
|
||||
context.getDriver().get(APP_URL);
|
||||
}
|
||||
|
||||
@After
|
||||
public void quit() {
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void albumList() throws ParseException {
|
||||
log.logp(INFO, getClass().getName(), "albumList", "List of albums test");
|
||||
|
||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||
mediaLib.selectMonthByPosition(1);
|
||||
|
||||
MediaLibPageHelper helper = new MediaLibPageHelper(mediaLib);
|
||||
Assert.assertTrue(helper.itemsAreInOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void photoList() {
|
||||
log.logp(INFO, getClass().getName(), "photoList", "List of photos test");
|
||||
|
||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||
int elementNumber = 0;
|
||||
String preview = mediaLib.getItemImageName(elementNumber);
|
||||
mediaLib.clickItemImage(elementNumber);
|
||||
|
||||
AlbumPage albumPage = PageFactory.initElements(context.getDriver(), AlbumPage.class);
|
||||
AlbumPageHelper helper = new AlbumPageHelper(albumPage);
|
||||
|
||||
Assert.assertTrue(helper.containsPreview(preview));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void photosView() throws InterruptedException, NoSuchMethodException {
|
||||
log.logp(INFO, getClass().getName(), "photosView", "View of photos test");
|
||||
|
||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||
mediaLib.clickItemImage(0);
|
||||
|
||||
AlbumPage albumPage = PageFactory.initElements(context.getDriver(), AlbumPage.class);
|
||||
AlbumPageHelper helper = new AlbumPageHelper(albumPage);
|
||||
helper.clickPhotoLink(0);
|
||||
|
||||
int elementNumber = 1;
|
||||
|
||||
Assert.assertTrue(helper.isSelectedPhoto(elementNumber));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void videoList() throws ParseException {
|
||||
log.logp(INFO, getClass().getName(), "videoList", "List of video test");
|
||||
|
||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||
mediaLib.clickVideoFilter();
|
||||
|
||||
MediaLibPageHelper helper = new MediaLibPageHelper(mediaLib);
|
||||
|
||||
Assert.assertTrue(helper.itemsAreInOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void videoPage () {
|
||||
log.logp(INFO, getClass().getName(), "videoPage", "Page with video test");
|
||||
|
||||
MediaLib mediaLibPhoto = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||
mediaLibPhoto.clickVideoFilter();
|
||||
|
||||
MediaLib mediaLibVideo = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||
|
||||
mediaLibVideo.clickItem(0);
|
||||
|
||||
VideoPage videoPage = PageFactory.initElements(context.getDriver(), VideoPage.class);
|
||||
|
||||
Assert.assertTrue(videoPage.isVideoPresent());
|
||||
}
|
||||
|
||||
|
||||
}
|
108
Semenova/src/test/java/NavigationTests.java
Normal file
108
Semenova/src/test/java/NavigationTests.java
Normal file
@ -0,0 +1,108 @@
|
||||
import Pages.*;
|
||||
import context.ChromeContext;
|
||||
import context.Context;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.openqa.selenium.Dimension;
|
||||
import org.openqa.selenium.support.PageFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
|
||||
public class NavigationTests {
|
||||
|
||||
private final static String APP_URL = "http://www.gazprom.ru/";
|
||||
private static java.util.logging.Logger log = Logger.getLogger(NavigationTests.class.getName());
|
||||
|
||||
private static Context context;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
context = new ChromeContext();
|
||||
context.start();
|
||||
context.getDriver().manage().window().setSize(new Dimension(1600, 900));
|
||||
|
||||
context.getDriver().get(APP_URL);
|
||||
}
|
||||
|
||||
@After
|
||||
public void quit() {
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void topMenuTest() {
|
||||
log.logp(INFO, getClass().getName(), "topMenuTest", "Top menu test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
|
||||
page.clickMenuElementPress();
|
||||
|
||||
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
||||
|
||||
Assert.assertTrue(pressPage.isNewsPresent());
|
||||
}
|
||||
@Test
|
||||
public void subMenu(){
|
||||
log.logp(INFO, getClass().getName(), "subMenu", "Sub menu test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
page.clickMenuElementPress();
|
||||
|
||||
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
||||
pressPage.clickMenuElementMedia();
|
||||
|
||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||
|
||||
Assert.assertTrue(mediaLib.isMediaListPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hyperlinks(){
|
||||
log.logp(INFO, getClass().getName(), "hyperlinks", "Hyperlinks test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
page.clickMenuElementAbout();
|
||||
|
||||
AboutPage aboutPage = PageFactory.initElements(context.getDriver(), AboutPage.class);
|
||||
aboutPage.clickHyperlinksMiningElement();
|
||||
|
||||
MiningPage miningPage = PageFactory.initElements(context.getDriver(), MiningPage.class);
|
||||
|
||||
Assert.assertTrue(miningPage.isMainContentPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sideMenu() {
|
||||
log.logp(INFO, getClass().getName(), "sideMenu", "Side menu test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
page.clickLayButton();
|
||||
page.clickMarketingLayMenuElement();
|
||||
|
||||
MarketingPage marketingPage = PageFactory.initElements(context.getDriver(), MarketingPage.class);
|
||||
|
||||
Assert.assertTrue(marketingPage.isMainContentPresent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void externalLinks() {
|
||||
log.logp(INFO, getClass().getName(), "externalLinks", "External links test");
|
||||
|
||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||
page.clickExternalSitesBtn();
|
||||
|
||||
int elementNumber = 0;
|
||||
String title = page.getTitleExternalLink(elementNumber);
|
||||
page.clickExternalLink(0);
|
||||
|
||||
ArrayList<String> tabs2 = new ArrayList<String> (context.getDriver().getWindowHandles());
|
||||
context.getDriver().switchTo().window(tabs2.get(1));
|
||||
|
||||
Assert.assertTrue(context.getDriver().getTitle().contains(title));
|
||||
}
|
||||
}
|
42
Semenova/src/test/java/PageHelpers/AlbumPageHelper.java
Normal file
42
Semenova/src/test/java/PageHelpers/AlbumPageHelper.java
Normal file
@ -0,0 +1,42 @@
|
||||
package PageHelpers;
|
||||
|
||||
import Pages.AlbumPage;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class AlbumPageHelper {
|
||||
private AlbumPage page;
|
||||
public AlbumPageHelper(AlbumPage page){
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public boolean containsPreview(String preview) {
|
||||
boolean containsPreview = false;
|
||||
for (int i = 0; i < page.getImagesCount(); i++) {
|
||||
String previewCur = page.getImageName(i);
|
||||
|
||||
if(preview.equals(previewCur)) {
|
||||
containsPreview = true;
|
||||
}
|
||||
}
|
||||
|
||||
return containsPreview;
|
||||
}
|
||||
|
||||
public boolean isSelectedPhoto(int elementNumber) throws NoSuchMethodException {
|
||||
|
||||
Method method = AlbumPageHelper.class.getMethod("clickAndCheckSelectedPhoto", int.class);
|
||||
return WaitingForElementToLoadHelper.waitAndCheckSelection(method,this,new Object[]{elementNumber});
|
||||
}
|
||||
|
||||
public void clickPhotoLink(int elementNumber) throws NoSuchMethodException {
|
||||
|
||||
Method method = AlbumPage.class.getMethod("clickPhotoLink", int.class);
|
||||
WaitingForElementToLoadHelper.waitAndCallMethod(method,page,new Object[]{elementNumber});
|
||||
}
|
||||
|
||||
public boolean clickAndCheckSelectedPhoto(int elementNumber){
|
||||
page.clickPhotoPopup();
|
||||
return page.isSelectedPhoto(elementNumber);
|
||||
}
|
||||
}
|
60
Semenova/src/test/java/PageHelpers/CalculatorPageHelper.java
Normal file
60
Semenova/src/test/java/PageHelpers/CalculatorPageHelper.java
Normal file
@ -0,0 +1,60 @@
|
||||
package PageHelpers;
|
||||
|
||||
import Pages.CalculatorPage;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static java.lang.Math.round;
|
||||
|
||||
public class CalculatorPageHelper {
|
||||
|
||||
private CalculatorPage page;
|
||||
Method insertInputMethod = CalculatorPageHelper.class.getMethod("insertInput", new Class[]{WebElement.class, String.class});
|
||||
|
||||
public CalculatorPageHelper(CalculatorPage page) throws NoSuchMethodException {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public boolean isCalculationRight( ){
|
||||
double startPrice = page.getStartPrice();
|
||||
double endPrice = page.getEndPrice();
|
||||
double reInvPrice = page.getReInvPrice();
|
||||
|
||||
double changePrice = page.getChangePrice();
|
||||
double changePriceRe = page.getChangePriceRe();
|
||||
double income = page.getIncome();
|
||||
|
||||
return isIncomeRight(startPrice,endPrice,income)
|
||||
&&isChangePriceRight(startPrice,changePrice,income)
|
||||
&&isChangePriceReRight(startPrice,changePriceRe,reInvPrice);
|
||||
}
|
||||
|
||||
private boolean isIncomeRight( double startPrice,double endPrice, double income){
|
||||
return ((double) round((endPrice-startPrice) * 100))/100==income;
|
||||
}
|
||||
private boolean isChangePriceRight( double startPrice,double changePrice, double income){
|
||||
return ((double) round(income/startPrice * 100*100))/100==changePrice;
|
||||
}
|
||||
private boolean isChangePriceReRight( double startPrice,double changePriceRe, double reInvPrice){
|
||||
return ((double) round((reInvPrice-startPrice)/startPrice*100 *100))/100 ==changePriceRe;
|
||||
}
|
||||
|
||||
public void waitAndInsertFromDate(String date) {
|
||||
WaitingForElementToLoadHelper.waitAndCallMethod(insertInputMethod,this,new Object[]{page.getFromDateInput(),date});
|
||||
}
|
||||
|
||||
public void insertInput(WebElement element,String text){
|
||||
element.clear();
|
||||
element.sendKeys(text);
|
||||
}
|
||||
|
||||
public void waitAndInsertToDate(String date){
|
||||
WaitingForElementToLoadHelper.waitAndCallMethod(insertInputMethod,this,new Object[]{page.getToDateInput(),date});
|
||||
}
|
||||
|
||||
public void waitAndInsertAmount(String amount){
|
||||
WaitingForElementToLoadHelper.waitAndCallMethod(insertInputMethod,this,new Object[]{page.getAmountInput(),amount});
|
||||
|
||||
}
|
||||
}
|
35
Semenova/src/test/java/PageHelpers/EventsPageHelper.java
Normal file
35
Semenova/src/test/java/PageHelpers/EventsPageHelper.java
Normal file
@ -0,0 +1,35 @@
|
||||
package PageHelpers;
|
||||
|
||||
import Pages.EventsPage;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
public class EventsPageHelper {
|
||||
|
||||
private EventsPage page;
|
||||
public EventsPageHelper(EventsPage page){
|
||||
this.page = page;
|
||||
}
|
||||
public boolean eventsMatchByMonth(int month) throws ParseException {
|
||||
|
||||
boolean suitable = true;
|
||||
DateFormat format = new SimpleDateFormat("d MMMM, hh:mm");
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
|
||||
for (int i = 0; i < page.getResultsCount(); i++) {
|
||||
Date dateCur = format.parse(page.getDateOfResult(i));
|
||||
calendar.setTime(dateCur);
|
||||
|
||||
if(calendar.get(Calendar.MONTH)!=month){
|
||||
suitable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return suitable;
|
||||
}
|
||||
}
|
16
Semenova/src/test/java/PageHelpers/FeedbackPageHelper.java
Normal file
16
Semenova/src/test/java/PageHelpers/FeedbackPageHelper.java
Normal file
@ -0,0 +1,16 @@
|
||||
package PageHelpers;
|
||||
|
||||
import Pages.FeedbackPage;
|
||||
|
||||
public class FeedbackPageHelper {
|
||||
private FeedbackPage page;
|
||||
String successMessage = "Ваше сообщение отправлено.";
|
||||
public FeedbackPageHelper(FeedbackPage page){
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public boolean isReceiveSuccess(){
|
||||
String output = page.getOutput();
|
||||
return output.equals(successMessage);
|
||||
}
|
||||
}
|
37
Semenova/src/test/java/PageHelpers/MediaLibPageHelper.java
Normal file
37
Semenova/src/test/java/PageHelpers/MediaLibPageHelper.java
Normal file
@ -0,0 +1,37 @@
|
||||
package PageHelpers;
|
||||
|
||||
import Pages.MediaLib;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
public class MediaLibPageHelper {
|
||||
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
||||
private MediaLib page;
|
||||
public MediaLibPageHelper(MediaLib page){
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public boolean itemsAreInOrder() throws ParseException {
|
||||
boolean order = true;
|
||||
DateFormat format = new SimpleDateFormat("yyyy.M.d H:m");
|
||||
Date datePrev = format.parse(page.getDateOfItem(0));
|
||||
|
||||
for (int i = 1; i < page.getItemsCount(); i++) {
|
||||
Date dateCur = format.parse(page.getDateOfItem(i));
|
||||
if(dateCur.after(datePrev)) {
|
||||
log.logp(WARNING, getClass().getName(), "albumList", "Date current: '"+dateCur +"', Date previous: '"+datePrev+"'");
|
||||
order = false;
|
||||
break;
|
||||
}
|
||||
datePrev = dateCur;
|
||||
}
|
||||
|
||||
return order;
|
||||
}
|
||||
}
|
23
Semenova/src/test/java/PageHelpers/PurchasePageHelper.java
Normal file
23
Semenova/src/test/java/PageHelpers/PurchasePageHelper.java
Normal file
@ -0,0 +1,23 @@
|
||||
package PageHelpers;
|
||||
|
||||
import Pages.PurchasesPage;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PurchasePageHelper {
|
||||
|
||||
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
||||
private PurchasesPage page;
|
||||
private int limit = 10;
|
||||
public PurchasePageHelper(PurchasesPage page){
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public boolean waitAndCheckPageSelection(int pageNumber) throws InterruptedException, NoSuchMethodException {
|
||||
|
||||
Method method = PurchasesPage.class.getMethod("isSelectedPage", int.class);
|
||||
return WaitingForElementToLoadHelper.waitAndCheckSelection(method,page,new Object[]{pageNumber});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package PageHelpers;
|
||||
|
||||
import Pages.SearchResultsPage;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
public class SearchResultsPageHelper {
|
||||
|
||||
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
||||
private SearchResultsPage page;
|
||||
public SearchResultsPageHelper(SearchResultsPage page){
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public boolean searchResultsMatchQueryAndInOrder(String queryString) throws ParseException, NoSuchMethodException {
|
||||
|
||||
boolean order = true;
|
||||
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
||||
Date datePrev = new Date();
|
||||
boolean matched = true;
|
||||
|
||||
for (int i = 0; i < page.getItemsCount(); i++) {
|
||||
Date dateCur = format.parse(waitAngGetItemsDate(i));
|
||||
|
||||
if(dateCur.after(datePrev)) {
|
||||
log.logp(WARNING, getClass().getName(), "simpleSearch", "Date current: '"+dateCur +"', Date previous: '"+datePrev+"'");
|
||||
order = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!waitAngGetItemsText(i).toLowerCase().contains(queryString)){
|
||||
log.logp(WARNING, getClass().getName(), "simpleSearch", "'" + waitAngGetItemsText(i)+"' is not suitable for '"+queryString+"'");
|
||||
matched = false;
|
||||
break;
|
||||
}
|
||||
|
||||
datePrev= dateCur;
|
||||
}
|
||||
return order&&matched;
|
||||
|
||||
}
|
||||
public boolean searchResultsMatchQueryYearAndInOrder(String queryString, int year) throws ParseException, NoSuchMethodException {
|
||||
boolean order = searchResultsMatchQueryAndInOrder(queryString);
|
||||
|
||||
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
boolean matched = true;
|
||||
|
||||
for (int i = 0; i < page.getItemsCount(); i++) {
|
||||
Date dateCur = format.parse(waitAngGetItemsDate(i));
|
||||
calendar.setTime(dateCur);
|
||||
|
||||
matched = matchedByYear(calendar,year);
|
||||
if(!matched){
|
||||
log.logp(WARNING, getClass().getName(), "searchResultsMatchQueryYearAndInOrder",
|
||||
" '"+calendar.get(Calendar.YEAR)+"' != '"+year+"'");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return order&&matched;
|
||||
}
|
||||
|
||||
private boolean matchedByYear(Calendar calendar,int year){
|
||||
return calendar.get(Calendar.YEAR)==year;
|
||||
}
|
||||
|
||||
public String waitAngGetItemsText(int itemNumber) throws NoSuchMethodException {
|
||||
|
||||
Method method = SearchResultsPage.class.getMethod("getItemsText", int.class);
|
||||
return (String)WaitingForElementToLoadHelper.waitAndCallMethod(method,page,new Object[]{itemNumber});
|
||||
|
||||
}
|
||||
|
||||
public String waitAngGetItemsDate(int itemNumber) throws NoSuchMethodException {
|
||||
|
||||
Method method = SearchResultsPage.class.getMethod("getItemsDate", int.class);
|
||||
return (String) WaitingForElementToLoadHelper.waitAndCallMethod(method, page, new Object[]{itemNumber});
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package PageHelpers;
|
||||
|
||||
import Pages.SubsidiariesPage;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
|
||||
public class SubsidiariesPageHelper {
|
||||
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
||||
private SubsidiariesPage page;
|
||||
public SubsidiariesPageHelper(SubsidiariesPage page){
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public boolean isOrder() throws Exception {
|
||||
|
||||
boolean order = checkPercents(page, "getPartOfItemPercent100","compareMethodEquals100",page.getItemsPercent100Count())
|
||||
&&checkPercents(page, "getPartOfItemPercentMore50","compareMethodMore50",page.getItemsPercentMore50Count())
|
||||
&&checkPercents(page, "getPartOfItemPercentLess50","compareMethodLess50",page.getItemsPercentLess50Count());
|
||||
|
||||
return order;
|
||||
}
|
||||
private boolean checkPercents( Object object, String getPartMethodName,String compareMethodName,int numberOfElements) throws Exception {
|
||||
|
||||
Method getPartMethod = SubsidiariesPage.class.getMethod(getPartMethodName,int.class);
|
||||
Method compareMethod = SubsidiariesPageHelper.class.getMethod(compareMethodName,float.class);
|
||||
|
||||
for (int i = 0; i < numberOfElements; i++) {
|
||||
float percent = (Float)(getPartMethod.invoke(object, i));
|
||||
|
||||
if(!(Boolean)(compareMethod.invoke(this, percent))){
|
||||
log.logp(WARNING, getClass().getName(), "sorting", getPartMethod.getName()+"!" +percent);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean compareMethodEquals100(float percent){
|
||||
return percent==100;
|
||||
}
|
||||
public boolean compareMethodMore50(float percent){
|
||||
return percent>50;
|
||||
}
|
||||
public boolean compareMethodLess50(float percent){
|
||||
return percent<=50;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package PageHelpers;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
public class WaitingForElementToLoadHelper {
|
||||
private static java.util.logging.Logger log = Logger.getLogger(WaitingForElementToLoadHelper.class.getName());
|
||||
static int tryLimit=10;
|
||||
static Object waitAndCallMethod(Method methodToCall,Object object,Object[] parameters ){
|
||||
|
||||
Object objectToReturn=null;
|
||||
boolean breakIt=false;
|
||||
int attemptNumber =0;
|
||||
while (!breakIt&&attemptNumber<tryLimit) {
|
||||
attemptNumber++;
|
||||
breakIt = true;
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
objectToReturn = methodToCall.invoke(object, parameters);
|
||||
} catch (Exception e) {
|
||||
log.logp(WARNING, WaitingForElementToLoadHelper.class.getName(), "waitAndCallMethod","Exception in waitAndCallMethod method");
|
||||
breakIt = false;
|
||||
}
|
||||
}
|
||||
return objectToReturn;
|
||||
}
|
||||
|
||||
static boolean waitAndCheckSelection(Method methodToCall,Object object,Object[] parameters ) {
|
||||
|
||||
boolean turn=false;
|
||||
int attemptNumber =0;
|
||||
while (!turn&&attemptNumber<tryLimit) {
|
||||
attemptNumber++;
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
turn=(Boolean)methodToCall.invoke(object, parameters);
|
||||
} catch (Exception e) {
|
||||
log.logp(WARNING, WaitingForElementToLoadHelper.class.getName(), "waitAndCheckSelection","Exception in waitAndCheckSelection method");
|
||||
}
|
||||
}
|
||||
|
||||
return turn;
|
||||
}
|
||||
|
||||
}
|
33
Semenova/src/test/java/Pages/AboutPage.java
Normal file
33
Semenova/src/test/java/Pages/AboutPage.java
Normal file
@ -0,0 +1,33 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AboutPage {
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".content_wrapper a")
|
||||
private List<WebElement> hyperlinkElements;
|
||||
|
||||
@FindBy(css = ".subnavigation li")
|
||||
private List<WebElement> subMenuElements;
|
||||
|
||||
private static int subsidariesPageMenuElementNumber = 4;
|
||||
private static int miningHyperLinkNumber = 0;
|
||||
|
||||
public AboutPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public void clickHyperlinksMiningElement(){
|
||||
hyperlinkElements.get(miningHyperLinkNumber).click();
|
||||
}
|
||||
|
||||
public void clickMenuElementSubsidaries(){
|
||||
subMenuElements.get(subsidariesPageMenuElementNumber).click();
|
||||
}
|
||||
|
||||
}
|
72
Semenova/src/test/java/Pages/AlbumPage.java
Normal file
72
Semenova/src/test/java/Pages/AlbumPage.java
Normal file
@ -0,0 +1,72 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebDriverException;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
|
||||
public class AlbumPage {
|
||||
|
||||
private WebDriverWait wait;
|
||||
private WebDriver driver;
|
||||
private static java.util.logging.Logger log = Logger.getLogger(AlbumPage.class.getName());
|
||||
|
||||
@FindBy(css = ".media__list .media__item img")
|
||||
private List<WebElement> albumImages;
|
||||
|
||||
@FindBy(css = ".media__popup__thumbs .media__popup__thumb img")
|
||||
private List<WebElement> photosPopupImg;
|
||||
|
||||
@FindBy(css = ".media__popup__thumbs .media__popup__thumb")
|
||||
private List<WebElement> photosPopup;
|
||||
|
||||
@FindBy(css = ".media__popup__thumbs .media__popup__thumb:not(.media__popup__thumb--selected)")
|
||||
private WebElement notSelectedThump;
|
||||
|
||||
public AlbumPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
wait = new WebDriverWait(driver,30,500);
|
||||
}
|
||||
|
||||
public String getImageName(int elementNumber){
|
||||
String imageName = albumImages.get(elementNumber).getAttribute("src");
|
||||
imageName = imageName.substring(imageName.lastIndexOf("/")+1);
|
||||
if(imageName.contains("_"))
|
||||
imageName = imageName.substring(imageName.lastIndexOf("_")+1);
|
||||
|
||||
return imageName;
|
||||
}
|
||||
|
||||
public int getImagesCount(){
|
||||
return albumImages.size();
|
||||
}
|
||||
|
||||
public void clickPhotoLink(int elementNumber) {
|
||||
wait.until(ExpectedConditions.visibilityOf(albumImages.get(elementNumber)));
|
||||
albumImages.get(elementNumber).click();
|
||||
}
|
||||
|
||||
public void clickPhotoPopup() {
|
||||
try{
|
||||
notSelectedThump.click();
|
||||
}catch (WebDriverException e){
|
||||
JavascriptExecutor executor = (JavascriptExecutor)driver;
|
||||
executor.executeScript("arguments[0].click()", notSelectedThump);
|
||||
log.logp(INFO, getClass().getName(), "clickPhotoPopup", "Exception in clickPhotoPopup method");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean isSelectedPhoto(int elementNumber){
|
||||
return photosPopup.get(elementNumber).getAttribute("class").contains("media__popup__thumb--selected");
|
||||
}
|
||||
}
|
118
Semenova/src/test/java/Pages/CalculatorPage.java
Normal file
118
Semenova/src/test/java/Pages/CalculatorPage.java
Normal file
@ -0,0 +1,118 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CalculatorPage {
|
||||
private WebDriverWait wait;
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".tbl_box #fromDate")
|
||||
private WebElement fromDateInput;
|
||||
|
||||
@FindBy(css = ".tbl_box #toDate")
|
||||
private WebElement toDateInput;
|
||||
|
||||
@FindBy(css = ".tbl_box #amountOfShares")
|
||||
private WebElement amountInput;
|
||||
|
||||
@FindBy(css = ".tbl_box table tr:nth-child(8) input")
|
||||
private WebElement calculateBtn;
|
||||
|
||||
@FindBy(css = ".result tr")
|
||||
private List<WebElement> tableElements;
|
||||
|
||||
@FindBy(css = ".result tr:nth-child(11) td:nth-child(2)")
|
||||
private WebElement startPrice;
|
||||
|
||||
@FindBy(css = ".result tr:nth-child(12) td:nth-child(2)")
|
||||
private WebElement endPrice;
|
||||
|
||||
@FindBy(css = ".result tr:nth-child(13) td:nth-child(3)")
|
||||
private WebElement reInvPrice;
|
||||
|
||||
@FindBy(css = ".result tr:nth-child(3) td:nth-child(2)")
|
||||
private WebElement changePrice;
|
||||
|
||||
@FindBy(css = ".result tr:nth-child(7) td:nth-child(2)")
|
||||
private WebElement changePriceRe;
|
||||
|
||||
@FindBy(css = ".result tr:nth-child(1) span")
|
||||
private WebElement income;
|
||||
|
||||
@FindBy(id = "ruCalc")
|
||||
private WebElement ruCalcFrame;
|
||||
|
||||
@FindBy(name = "chart")
|
||||
private WebElement chartFrame;
|
||||
|
||||
public CalculatorPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
wait = new WebDriverWait(driver,30,500);
|
||||
}
|
||||
|
||||
public void switchToCalcFrame(){
|
||||
wait.until(ExpectedConditions.visibilityOf(ruCalcFrame));
|
||||
driver.switchTo().frame(ruCalcFrame);
|
||||
wait.until(ExpectedConditions.visibilityOf(chartFrame));
|
||||
driver.switchTo().frame(chartFrame);
|
||||
|
||||
}
|
||||
|
||||
public void clickCalcBtn(){
|
||||
calculateBtn.click();
|
||||
}
|
||||
|
||||
public double getStartPrice(){
|
||||
|
||||
String tmp = startPrice.getText();
|
||||
tmp = tmp.substring(0,tmp.lastIndexOf(" ")+1);
|
||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||
}
|
||||
|
||||
public double getEndPrice(){
|
||||
String tmp = endPrice.getText();
|
||||
tmp = tmp.substring(0,tmp.lastIndexOf(" ")+1);
|
||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||
}
|
||||
|
||||
public double getReInvPrice(){
|
||||
String tmp = reInvPrice.getText();
|
||||
tmp = tmp.substring(0,tmp.lastIndexOf(" ")+1);
|
||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||
}
|
||||
|
||||
public double getChangePrice(){
|
||||
String tmp = changePrice.getText();
|
||||
tmp = tmp.substring(0,tmp.lastIndexOf("%"));
|
||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||
}
|
||||
|
||||
public double getChangePriceRe(){
|
||||
String tmp = changePriceRe.getText();
|
||||
tmp = tmp.substring(0,tmp.lastIndexOf("%"));
|
||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||
}
|
||||
|
||||
public double getIncome(){
|
||||
String tmp = income.getText();
|
||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||
}
|
||||
|
||||
public WebElement getFromDateInput() {
|
||||
return fromDateInput;
|
||||
}
|
||||
|
||||
public WebElement getToDateInput() {
|
||||
return toDateInput;
|
||||
}
|
||||
|
||||
public WebElement getAmountInput() {
|
||||
return amountInput;
|
||||
}
|
||||
}
|
42
Semenova/src/test/java/Pages/EventsPage.java
Normal file
42
Semenova/src/test/java/Pages/EventsPage.java
Normal file
@ -0,0 +1,42 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EventsPage {
|
||||
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".years-navigation li")
|
||||
private List<WebElement> yearsFilter;
|
||||
|
||||
@FindBy(css = ".years-navigation__months li")
|
||||
private List<WebElement> monthFilter;
|
||||
|
||||
@FindBy(css = ".news-list li .date")
|
||||
private List<WebElement> searchResultsDates;
|
||||
|
||||
public EventsPage (WebDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public void selectYearByPosition(int itemNumber){
|
||||
yearsFilter.get(itemNumber).click();
|
||||
}
|
||||
|
||||
public void selectMonthByPosition(int itemNumber){
|
||||
monthFilter.get(itemNumber).click();
|
||||
}
|
||||
|
||||
public String getDateOfResult(int itemNumber){
|
||||
return searchResultsDates.get(itemNumber).getText();
|
||||
}
|
||||
|
||||
public int getResultsCount(){
|
||||
return searchResultsDates.size();
|
||||
}
|
||||
|
||||
}
|
49
Semenova/src/test/java/Pages/FeedbackPage.java
Normal file
49
Semenova/src/test/java/Pages/FeedbackPage.java
Normal file
@ -0,0 +1,49 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
|
||||
public class FeedbackPage {
|
||||
private WebDriverWait wait;
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(id = "email")
|
||||
private WebElement emailInput;
|
||||
|
||||
@FindBy(id = "text")
|
||||
private WebElement textInput;
|
||||
|
||||
@FindBy(id = "btnSubmit")
|
||||
private WebElement btnSubmit;
|
||||
|
||||
@FindBy(id = "output")
|
||||
private WebElement output;
|
||||
|
||||
public FeedbackPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
wait = new WebDriverWait(driver,30,500);
|
||||
}
|
||||
|
||||
public void insertEmail(String email){
|
||||
emailInput.sendKeys(email);
|
||||
}
|
||||
|
||||
public void insertText(String text){
|
||||
textInput.sendKeys(text);
|
||||
}
|
||||
|
||||
public void submitFeedback(){
|
||||
btnSubmit.click();
|
||||
}
|
||||
|
||||
public String getOutput(){
|
||||
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("output")));
|
||||
|
||||
return output.getText();
|
||||
}
|
||||
}
|
32
Semenova/src/test/java/Pages/ForShareholders.java
Normal file
32
Semenova/src/test/java/Pages/ForShareholders.java
Normal file
@ -0,0 +1,32 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ForShareholders {
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".reports_cont .file a")
|
||||
private List<WebElement> downloadLinks;
|
||||
|
||||
@FindBy(css = ".subnavigation li")
|
||||
private List<WebElement> subMenuElements;
|
||||
|
||||
public ForShareholders(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public String getFileName(int elementNumber){
|
||||
String fileName = downloadLinks.get(elementNumber).getAttribute("href");
|
||||
fileName = fileName.substring(fileName.lastIndexOf("/")+1);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void clickDownloadLink(int elementNumber){
|
||||
downloadLinks.get(elementNumber).click();
|
||||
}
|
||||
|
||||
}
|
36
Semenova/src/test/java/Pages/JournalsPage.java
Normal file
36
Semenova/src/test/java/Pages/JournalsPage.java
Normal file
@ -0,0 +1,36 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JournalsPage {
|
||||
|
||||
private WebDriverWait wait;
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".journals__img-link")
|
||||
private List<WebElement> imgLinks;
|
||||
|
||||
|
||||
public JournalsPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
wait = new WebDriverWait(driver,30,500);
|
||||
}
|
||||
|
||||
public void clickImgLink(int elementNumber){
|
||||
wait.until(ExpectedConditions.visibilityOfAllElements(imgLinks));
|
||||
imgLinks.get(elementNumber).click();
|
||||
}
|
||||
|
||||
public String getFileName(int elementNumber){
|
||||
String fileName = imgLinks.get(elementNumber).getAttribute("href");
|
||||
fileName = fileName.substring(fileName.lastIndexOf("/")+1);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
}
|
102
Semenova/src/test/java/Pages/MainPage.java
Normal file
102
Semenova/src/test/java/Pages/MainPage.java
Normal file
@ -0,0 +1,102 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.Keys;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MainPage {
|
||||
private WebDriverWait wait;
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".navigation li")
|
||||
private List<WebElement> menuElements;
|
||||
|
||||
@FindBy(css = ".lay_button")
|
||||
private WebElement layButton;
|
||||
|
||||
@FindBy(css = ".menu-map__col a")
|
||||
private List<WebElement> layMenuElements;
|
||||
|
||||
@FindBy(id = "sites_link")
|
||||
private WebElement externalSitesBtn;
|
||||
|
||||
@FindBy(css = "#sites_list .column_wrapper a")
|
||||
private List<WebElement> externalLinks;
|
||||
|
||||
@FindBy(css = ".main_menu_search")
|
||||
private WebElement searchBtn;
|
||||
|
||||
@FindBy(id = "search-field__query")
|
||||
private WebElement searchField;
|
||||
|
||||
@FindBy(css = ".additional_top_navigation a")
|
||||
private List<WebElement> additionalMenu;
|
||||
|
||||
private static int shareholdersPageMenuElementNumber = 1;
|
||||
private static int aboutPageMenuElementNumber = 0;
|
||||
private static int pressPageMenuElementNumber = 2;
|
||||
private static int purchasePageMenuElementNumber = 1;
|
||||
private static int marketingPageMenuElementNumber = 3;
|
||||
|
||||
public MainPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
wait = new WebDriverWait(driver,30,500);
|
||||
}
|
||||
|
||||
public void clickMenuElementShareholder(){
|
||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements.get(shareholdersPageMenuElementNumber)));
|
||||
menuElements.get(shareholdersPageMenuElementNumber).click();
|
||||
}
|
||||
public void clickMenuElementAbout(){
|
||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements.get(shareholdersPageMenuElementNumber)));
|
||||
menuElements.get(aboutPageMenuElementNumber).click();
|
||||
}
|
||||
public void clickMenuElementPress(){
|
||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements.get(shareholdersPageMenuElementNumber)));
|
||||
menuElements.get(pressPageMenuElementNumber).click();
|
||||
}
|
||||
|
||||
public void clickLayButton(){
|
||||
layButton.click();
|
||||
}
|
||||
public void clickMarketingLayMenuElement(){
|
||||
layMenuElements.get(marketingPageMenuElementNumber).click();
|
||||
}
|
||||
|
||||
public void clickExternalSitesBtn(){
|
||||
externalSitesBtn.click();
|
||||
}
|
||||
|
||||
public void clickExternalLink(int elementNumber) {
|
||||
wait.until(ExpectedConditions.visibilityOfAllElements(externalLinks.get(elementNumber)));
|
||||
externalLinks.get(elementNumber).click();
|
||||
}
|
||||
|
||||
public String getTitleExternalLink(int elementNumber) {
|
||||
wait.until(ExpectedConditions.visibilityOfAllElements(externalLinks.get(elementNumber)));
|
||||
|
||||
return externalLinks.get(elementNumber).getText();
|
||||
}
|
||||
|
||||
public void clickSearchBtn(){
|
||||
searchBtn.click();
|
||||
}
|
||||
|
||||
public void insertSearchText(String text){
|
||||
wait.until(ExpectedConditions.visibilityOf(searchField));
|
||||
searchField.sendKeys(text);
|
||||
}
|
||||
|
||||
public void submitSearch(){
|
||||
searchField.sendKeys(Keys.RETURN);
|
||||
}
|
||||
|
||||
public void clickAdditionalMenuElementPurchase(){
|
||||
additionalMenu.get(purchasePageMenuElementNumber).click();
|
||||
}
|
||||
}
|
21
Semenova/src/test/java/Pages/MarketingPage.java
Normal file
21
Semenova/src/test/java/Pages/MarketingPage.java
Normal file
@ -0,0 +1,21 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
public class MarketingPage {
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".main-content")
|
||||
private WebElement mainContentElement;
|
||||
|
||||
|
||||
public MarketingPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public boolean isMainContentPresent(){
|
||||
return mainContentElement.isDisplayed();
|
||||
}
|
||||
}
|
97
Semenova/src/test/java/Pages/MediaLib.java
Normal file
97
Semenova/src/test/java/Pages/MediaLib.java
Normal file
@ -0,0 +1,97 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MediaLib {
|
||||
private WebDriverWait wait;
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".media__list:first-child .media__item .media__date:first-child")
|
||||
private List<WebElement> itemsDates;
|
||||
|
||||
@FindBy(css = ".media__list:first-child .media__item .media__name a")
|
||||
private List<WebElement> itemsTitles;
|
||||
|
||||
@FindBy(css = ".media__list:first-child .media__item a:first-child")
|
||||
private List<WebElement> itemsLinks;
|
||||
|
||||
@FindBy(css = ".media__list:first-child .media__item a:first-child img")
|
||||
private List<WebElement> albumsImages;
|
||||
|
||||
@FindBy(css = ".content__filter a")
|
||||
private List<WebElement> contentFilter;
|
||||
|
||||
@FindBy(css = ".years-navigation__months li")
|
||||
private List<WebElement> monthFilter;
|
||||
|
||||
@FindBy(css = ".media__popup__social span")
|
||||
private List<WebElement> socialLinks;
|
||||
|
||||
@FindBy(css = ".h1--semi-margin-bottom")
|
||||
private WebElement albumTitle;
|
||||
|
||||
@FindBy(css = ".media__list ")
|
||||
private WebElement mediaListElement;
|
||||
|
||||
private static int socialLinkTwitter = 2;
|
||||
|
||||
public MediaLib(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
wait = new WebDriverWait(driver,10,500);
|
||||
}
|
||||
|
||||
public String getDateOfItem(int elementNumber){
|
||||
wait.until(ExpectedConditions.visibilityOfAllElements(itemsDates.get(elementNumber)));
|
||||
return itemsDates.get(elementNumber).getAttribute("value");
|
||||
}
|
||||
|
||||
public int getItemsCount(){
|
||||
return itemsDates.size();
|
||||
}
|
||||
|
||||
public void clickItemImage(int elementNumber){
|
||||
wait.until(ExpectedConditions.visibilityOf( albumsImages.get(elementNumber)));
|
||||
albumsImages.get(elementNumber).click();
|
||||
}
|
||||
|
||||
public String getItemImageName(int elementNumber){
|
||||
wait.until(ExpectedConditions.visibilityOf(albumsImages.get(elementNumber)));
|
||||
String preview = albumsImages.get(elementNumber).getAttribute("src");
|
||||
preview = preview.substring(preview.lastIndexOf("_")+1);
|
||||
|
||||
return preview;
|
||||
}
|
||||
|
||||
public void clickVideoFilter() {
|
||||
contentFilter.get(0).click();
|
||||
}
|
||||
|
||||
public void clickItem(int elementNumber){
|
||||
itemsLinks.get(elementNumber).click();
|
||||
}
|
||||
|
||||
public void selectMonthByPosition(int itemNumber){
|
||||
monthFilter.get(itemNumber).click();
|
||||
}
|
||||
|
||||
public void clickSocialLinkTwitter(){
|
||||
socialLinks.get(socialLinkTwitter).click();
|
||||
}
|
||||
|
||||
public void switchToTwitterPopup(){
|
||||
|
||||
for (String winHandle : driver.getWindowHandles()) {
|
||||
driver.switchTo().window(winHandle);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isMediaListPresent(){
|
||||
return mediaListElement.isDisplayed();
|
||||
}
|
||||
}
|
21
Semenova/src/test/java/Pages/MiningPage.java
Normal file
21
Semenova/src/test/java/Pages/MiningPage.java
Normal file
@ -0,0 +1,21 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
public class MiningPage {
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".main-content")
|
||||
private WebElement mainContentElement;
|
||||
|
||||
|
||||
public MiningPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public boolean isMainContentPresent(){
|
||||
return mainContentElement.isDisplayed();
|
||||
}
|
||||
}
|
47
Semenova/src/test/java/Pages/PressPage.java
Normal file
47
Semenova/src/test/java/Pages/PressPage.java
Normal file
@ -0,0 +1,47 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PressPage {
|
||||
private WebDriverWait wait;
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".subnavigation li")
|
||||
private List<WebElement> menuElements;
|
||||
|
||||
@FindBy(css = ".news-list")
|
||||
private WebElement newsElement;
|
||||
|
||||
private static int journalPageMenuElementNumber = 2;
|
||||
private static int mediaPageMenuElementNumber = 1;
|
||||
private static int eventPageMenuElementNumber = 0;
|
||||
|
||||
public PressPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
wait = new WebDriverWait(driver,30,500);
|
||||
}
|
||||
|
||||
public void clickMenuElementJournal(){
|
||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
||||
menuElements.get(journalPageMenuElementNumber).click();
|
||||
}
|
||||
public void clickMenuElementEventPage(){
|
||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
||||
menuElements.get(eventPageMenuElementNumber).click();
|
||||
}
|
||||
public void clickMenuElementMedia(){
|
||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
||||
menuElements.get(mediaPageMenuElementNumber).click();
|
||||
}
|
||||
|
||||
public boolean isNewsPresent(){
|
||||
return newsElement.isDisplayed();
|
||||
}
|
||||
|
||||
}
|
49
Semenova/src/test/java/Pages/PurchasesPage.java
Normal file
49
Semenova/src/test/java/Pages/PurchasesPage.java
Normal file
@ -0,0 +1,49 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PurchasesPage {
|
||||
private WebDriverWait wait;
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".subnavigation a")
|
||||
private List<WebElement> menuElements;
|
||||
|
||||
@FindBy(css = ".text_data tbody tr")
|
||||
private List<WebElement> searchResults;
|
||||
|
||||
@FindBy(css = ".text_data tbody tr td:nth-child(2) p:first-child span")
|
||||
private List<WebElement> purchasesNumbers;
|
||||
|
||||
@FindBy(css = ".dataTables_paginate span")
|
||||
private List<WebElement> paginationElements;
|
||||
|
||||
private static int feedbackMenuElementNumber = 10;
|
||||
private static int inWorkPurchaseMenuElementNumber = 2;
|
||||
|
||||
public PurchasesPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
wait = new WebDriverWait(driver,30,500);
|
||||
}
|
||||
|
||||
public void clickMenuItemInWork(){
|
||||
menuElements.get(inWorkPurchaseMenuElementNumber).click();
|
||||
}
|
||||
public void clickMenuItemFeedback(){
|
||||
menuElements.get(feedbackMenuElementNumber).click();
|
||||
}
|
||||
|
||||
public void clickPage(int pageNumber){
|
||||
paginationElements.get(pageNumber).click();
|
||||
}
|
||||
|
||||
public boolean isSelectedPage(int pageNumber){
|
||||
boolean isSelect = paginationElements.get(pageNumber).getAttribute("class").equals("paginate_active");
|
||||
return isSelect;
|
||||
}
|
||||
}
|
55
Semenova/src/test/java/Pages/SearchResultsPage.java
Normal file
55
Semenova/src/test/java/Pages/SearchResultsPage.java
Normal file
@ -0,0 +1,55 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SearchResultsPage {
|
||||
|
||||
private WebDriverWait wait;
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".search_results .search_results__item[data-ng-repeat='item in searchResults'] .search_results__date")
|
||||
private List<WebElement> searchResultsDates;
|
||||
|
||||
@FindBy(css = ".search_results .search_results__item[data-ng-repeat='item in searchResults'] .search_results__text")
|
||||
private List<WebElement> searchResultsTexts;
|
||||
|
||||
@FindBy(css = ".toggle span")
|
||||
private WebElement filterOn;
|
||||
|
||||
@FindBy(css = ".search__tags--years .tag-button")
|
||||
private List<WebElement> yearsFilter;
|
||||
|
||||
public SearchResultsPage (WebDriver driver) {
|
||||
this.driver = driver;
|
||||
wait = new WebDriverWait(driver,30,500);
|
||||
}
|
||||
|
||||
public String getItemsText(int itemNumber){
|
||||
|
||||
return searchResultsTexts.get(itemNumber).getText();
|
||||
}
|
||||
|
||||
public String getItemsDate(int itemNumber){
|
||||
return searchResultsDates.get(itemNumber).getAttribute("value");
|
||||
}
|
||||
|
||||
public int getItemsCount() {
|
||||
int size = searchResultsTexts.size();
|
||||
return size;
|
||||
|
||||
}
|
||||
|
||||
public void setFilterOn(){
|
||||
filterOn.click();
|
||||
}
|
||||
|
||||
public void selectYearByPosition(int itemNumber){
|
||||
yearsFilter.get(itemNumber).click();
|
||||
}
|
||||
|
||||
}
|
57
Semenova/src/test/java/Pages/SubsidiariesPage.java
Normal file
57
Semenova/src/test/java/Pages/SubsidiariesPage.java
Normal file
@ -0,0 +1,57 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SubsidiariesPage {
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".filters p *")
|
||||
private List<WebElement> filtersLinks;
|
||||
|
||||
@FindBy(css = ".company_list ul:nth-child(2) .gazprom_part")
|
||||
private List<WebElement> itemsPercent100;
|
||||
|
||||
@FindBy(css = ".company_list ul:nth-child(6) .gazprom_part")
|
||||
private List<WebElement> itemsPercentMore50;
|
||||
|
||||
@FindBy(css = ".company_list ul:nth-child(8) .gazprom_part")
|
||||
private List<WebElement> itemsPercentLess50;
|
||||
|
||||
public SubsidiariesPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public void clickPercentFilter(){
|
||||
filtersLinks.get(1).click();
|
||||
}
|
||||
|
||||
public int getItemsPercent100Count(){
|
||||
return itemsPercent100.size();
|
||||
}
|
||||
|
||||
public int getItemsPercentMore50Count(){
|
||||
return itemsPercentMore50.size();
|
||||
}
|
||||
public int getItemsPercentLess50Count(){
|
||||
return itemsPercentLess50.size();
|
||||
}
|
||||
|
||||
public float getPartOfItemPercent100(int itemNumber){
|
||||
String per = itemsPercent100.get(itemNumber).getText().split("%")[0];
|
||||
return Float.parseFloat(per.substring(per.lastIndexOf(" ")+1).replace(",","."));
|
||||
}
|
||||
|
||||
public float getPartOfItemPercentMore50(int itemNumber){
|
||||
String per = itemsPercentMore50.get(itemNumber).getText().split("%")[0];
|
||||
return Float.parseFloat(per.substring(per.lastIndexOf(" ")+1).replace(",","."));
|
||||
}
|
||||
|
||||
public float getPartOfItemPercentLess50(int itemNumber){
|
||||
String per = itemsPercentLess50.get(itemNumber).getText().split("%")[0];
|
||||
return Float.parseFloat(per.substring(per.lastIndexOf(" ")+1).replace(",","."));
|
||||
}
|
||||
}
|
26
Semenova/src/test/java/Pages/TwitterSharingPopup.java
Normal file
26
Semenova/src/test/java/Pages/TwitterSharingPopup.java
Normal file
@ -0,0 +1,26 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
public class TwitterSharingPopup {
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(id = "username_or_email")
|
||||
private WebElement usernameInput;
|
||||
|
||||
@FindBy(id = "password")
|
||||
private WebElement passInput;
|
||||
|
||||
@FindBy(css = ".submit")
|
||||
private WebElement submitBtn;
|
||||
|
||||
public TwitterSharingPopup(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public boolean isSubmitBtnPresent(){
|
||||
return submitBtn.isDisplayed();
|
||||
}
|
||||
}
|
33
Semenova/src/test/java/Pages/VideoPage.java
Normal file
33
Semenova/src/test/java/Pages/VideoPage.java
Normal file
@ -0,0 +1,33 @@
|
||||
package Pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VideoPage {
|
||||
|
||||
private WebDriver driver;
|
||||
|
||||
@FindBy(css = ".media__list .media__item img")
|
||||
private List<WebElement> albumImages;
|
||||
|
||||
@FindBy(css = ".media__popup__thumbs .media__popup__thumb")
|
||||
private List<WebElement> photosPopup;
|
||||
|
||||
@FindBy(css = ".media_filter h1")
|
||||
private WebElement videoTitle;
|
||||
|
||||
@FindBy(css = ".media__iframe")
|
||||
private WebElement videoElement;
|
||||
|
||||
public VideoPage(WebDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public boolean isVideoPresent(){
|
||||
return videoElement.isDisplayed();
|
||||
}
|
||||
|
||||
}
|
39
Semenova/src/test/java/context/ChromeContext.java
Normal file
39
Semenova/src/test/java/context/ChromeContext.java
Normal file
@ -0,0 +1,39 @@
|
||||
package context;
|
||||
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.chrome.ChromeOptions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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() {
|
||||
ChromeOptions options = new ChromeOptions();
|
||||
Map<String, Object> prefs = new HashMap<String, Object>();
|
||||
|
||||
tmpPath = System.getProperty("user.dir") + "/src/main/resources/downloads/";
|
||||
|
||||
prefs.put("download.default_directory", tmpPath);
|
||||
prefs.put("plugins.always_open_pdf_externally", true);
|
||||
|
||||
options.setExperimentalOption("prefs",prefs);
|
||||
driver = new ChromeDriver(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverExecutable(boolean isWindows) {
|
||||
return isWindows ? WINDOWS_DRIVER : LINUX_DRIVER;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDriverType() {
|
||||
return DRIVER_TYPE;
|
||||
}
|
||||
|
||||
}
|
50
Semenova/src/test/java/context/Context.java
Normal file
50
Semenova/src/test/java/context/Context.java
Normal file
@ -0,0 +1,50 @@
|
||||
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;
|
||||
|
||||
protected String tmpPath;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
public String getTmpPath(){
|
||||
return tmpPath;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user