Added helpers, logs
This commit is contained in:
parent
0deb6f91e2
commit
fc913632db
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
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
import PageHelpers.CalculatorPageHelper;
|
||||||
import Pages.CalculatorPage;
|
import Pages.CalculatorPage;
|
||||||
import context.ChromeContext;
|
import context.ChromeContext;
|
||||||
import context.Context;
|
import context.Context;
|
||||||
@ -8,10 +9,14 @@ import org.junit.Test;
|
|||||||
import org.openqa.selenium.Dimension;
|
import org.openqa.selenium.Dimension;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
|
||||||
public class CalculatorTest {
|
public class CalculatorTest {
|
||||||
|
|
||||||
private final static String APP_URL = "http://www.gazprom.ru/investors/stock/investor-tools/calc/";
|
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;
|
private static Context context;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -25,40 +30,28 @@ public class CalculatorTest {
|
|||||||
|
|
||||||
@After
|
@After
|
||||||
public void quit() {
|
public void quit() {
|
||||||
|
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void countInvestor() throws InterruptedException {
|
public void countInvestor() throws InterruptedException {
|
||||||
System.out.println("Investor's count test");
|
log.logp(INFO, getClass().getName(), "countInvestor", "Investor's count test");
|
||||||
|
|
||||||
|
|
||||||
Thread.sleep(1000);
|
|
||||||
|
|
||||||
CalculatorPage calculatorPage = PageFactory.initElements(context.getDriver(), CalculatorPage.class);
|
CalculatorPage calculatorPage = PageFactory.initElements(context.getDriver(), CalculatorPage.class);
|
||||||
calculatorPage.switchToCalcFrame();
|
calculatorPage.switchToCalcFrame();
|
||||||
|
|
||||||
calculatorPage.insertFromDate("30.09.2011");
|
CalculatorPageHelper calculatorPageHelper = new CalculatorPageHelper(calculatorPage);
|
||||||
calculatorPage.insertToDate("01.02.2018");
|
|
||||||
calculatorPage.insertAmount("1");
|
calculatorPageHelper.waitAndInsertFromDate("30.09.2011");
|
||||||
|
calculatorPageHelper.waitAndInsertToDate("01.02.2018");
|
||||||
|
calculatorPageHelper.waitAndInsertAmount("1");
|
||||||
|
|
||||||
calculatorPage.clickCalcBtn();
|
calculatorPage.clickCalcBtn();
|
||||||
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
|
||||||
double startPrice = calculatorPage.getStartPrice();
|
|
||||||
double endPrice = calculatorPage.getEndPrice();
|
|
||||||
double reInvPrice = calculatorPage.getReInvPrice();
|
|
||||||
|
|
||||||
double changePrice = calculatorPage.getChangePrice();
|
Assert.assertTrue(calculatorPageHelper.isCalculationRight());
|
||||||
double changePriceRe = calculatorPage.getChangePriceRe();
|
|
||||||
double income = calculatorPage.getIncome();
|
|
||||||
|
|
||||||
// System.out.println(startPrice+"!"+endPrice+"!"+reInvPrice+"!"+changePrice+"!"+changePriceRe+"!"+income+"!");
|
|
||||||
|
|
||||||
|
|
||||||
Assert.assertTrue(((double)Math.round((endPrice-startPrice) * 100))/100==income
|
|
||||||
&&((double)Math.round(income/startPrice * 100*100))/100==changePrice
|
|
||||||
&&((double)Math.round((reInvPrice-startPrice)/startPrice*100 *100))/100 ==changePriceRe);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,15 @@ import org.openqa.selenium.Dimension;
|
|||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
|
||||||
public class DocumentTests {
|
public class DocumentTests {
|
||||||
|
|
||||||
private final static String APP_URL = "http://www.gazprom.ru/";
|
private final static String APP_URL = "http://www.gazprom.ru/";
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(DocumentTests.class.getName());
|
||||||
private static Context context;
|
private static Context context;
|
||||||
|
|
||||||
private String tmpPath;
|
private String tmpPath;
|
||||||
@ -39,25 +43,29 @@ public class DocumentTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void downloadDocs() throws InterruptedException {
|
public void downloadDocs() throws InterruptedException {
|
||||||
System.out.println("Downloading test");
|
log.logp(INFO, getClass().getName(), "downloadDocs", "Downloading test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
page.clickMenuElement(1);
|
page.clickMenuElementShareholder();
|
||||||
|
|
||||||
ForShareholders shareholdersPage = PageFactory.initElements(context.getDriver(), ForShareholders.class);
|
ForShareholders shareholdersPage = PageFactory.initElements(context.getDriver(), ForShareholders.class);
|
||||||
int elementNumber = 0;
|
int elementNumber = 0;
|
||||||
String fileName = shareholdersPage.getFileName(elementNumber);
|
String fileName = shareholdersPage.getFileName(elementNumber);
|
||||||
shareholdersPage.clickDownloadLink(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);
|
File f = new File(tmpPath +fileName);
|
||||||
System.out.println(tmpPath + fileName);
|
int time=0;
|
||||||
|
while(!f.exists()&&time<timeout){
|
||||||
int timeout=0;
|
Thread.sleep(period);
|
||||||
while(!f.exists()&&timeout<100){
|
time++;
|
||||||
Thread.sleep(500);
|
|
||||||
timeout++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertTrue(f.exists());
|
Assert.assertTrue(f.exists());
|
||||||
if(f.exists()) {
|
if(f.exists()) {
|
||||||
f.delete();
|
f.delete();
|
||||||
@ -66,33 +74,22 @@ public class DocumentTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void downloadJournal() throws InterruptedException {
|
public void downloadJournal() throws InterruptedException {
|
||||||
System.out.println("Downloading journal test");
|
log.logp(INFO, getClass().getName(), "downloadJournal", "Downloading journal test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
page.clickMenuElement(2);
|
page.clickMenuElementPress();
|
||||||
|
|
||||||
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
||||||
pressPage.clickMenuElement(2);
|
pressPage.clickMenuElementJournal();
|
||||||
|
|
||||||
JournalsPage journalsPage = PageFactory.initElements(context.getDriver(), JournalsPage.class);
|
JournalsPage journalsPage = PageFactory.initElements(context.getDriver(), JournalsPage.class);
|
||||||
int elementNumber = 0;
|
int elementNumber = 0;
|
||||||
String fileName = journalsPage.getFileName(elementNumber);
|
String fileName = journalsPage.getFileName(elementNumber);
|
||||||
journalsPage.clickImgLink(elementNumber);
|
journalsPage.clickImgLink(elementNumber);
|
||||||
|
|
||||||
File f = new File(tmpPath +fileName);
|
log.logp(INFO, getClass().getName(), "downloadJournal", "Path: "+tmpPath +fileName);
|
||||||
System.out.println(tmpPath + fileName);
|
|
||||||
|
|
||||||
int timeout=0;
|
|
||||||
while(!f.exists()&&timeout<150){
|
|
||||||
Thread.sleep(1000);
|
|
||||||
timeout++;
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertTrue(f.exists());
|
|
||||||
if(f.exists()) {
|
|
||||||
f.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
checkDownload(fileName,150,1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import PageHelpers.FeedbackPageHelper;
|
||||||
import Pages.*;
|
import Pages.*;
|
||||||
import context.ChromeContext;
|
import context.ChromeContext;
|
||||||
import context.Context;
|
import context.Context;
|
||||||
@ -7,17 +8,19 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.openqa.selenium.Dimension;
|
import org.openqa.selenium.Dimension;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
import twitter4j.*;
|
|
||||||
import twitter4j.conf.ConfigurationBuilder;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
|
||||||
public class FeedbackTests {
|
public class FeedbackTests {
|
||||||
|
|
||||||
private final static String APP_URL = "http://www.gazprom.ru/";
|
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;
|
private static Context context;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
context = new ChromeContext();
|
context = new ChromeContext();
|
||||||
@ -29,55 +32,52 @@ public class FeedbackTests {
|
|||||||
|
|
||||||
@After
|
@After
|
||||||
public void quit() {
|
public void quit() {
|
||||||
|
|
||||||
context.close();
|
context.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void offer() {
|
public void offer() {
|
||||||
System.out.println("Offer test");
|
log.logp(INFO, getClass().getName(), "offer", "Offer test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
page.clickAdditionalMenuElement(1);
|
page.clickAdditionalMenuElementPurchase();
|
||||||
|
|
||||||
PurchasesPage purchasesPage = PageFactory.initElements(context.getDriver(), PurchasesPage.class);
|
PurchasesPage purchasesPage = PageFactory.initElements(context.getDriver(), PurchasesPage.class);
|
||||||
purchasesPage.clickMenuItem(10);
|
purchasesPage.clickMenuItemFeedback();
|
||||||
|
|
||||||
FeedbackPage feedbackPage = PageFactory.initElements(context.getDriver(), FeedbackPage.class);
|
FeedbackPage feedbackPage = PageFactory.initElements(context.getDriver(), FeedbackPage.class);
|
||||||
feedbackPage.insertEmail("test@mail.ru");
|
feedbackPage.insertEmail("test@mail.ru");
|
||||||
feedbackPage.insertText("test text");
|
feedbackPage.insertText("test text");
|
||||||
feedbackPage.submitFeedback();
|
feedbackPage.submitFeedback();
|
||||||
|
|
||||||
String output = feedbackPage.getOutput();
|
FeedbackPageHelper helper = new FeedbackPageHelper(feedbackPage);
|
||||||
|
|
||||||
Assert.assertTrue(output.equals("Ваше сообщение отправлено."));
|
Assert.assertTrue(helper.isReceiveSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shareFunction() throws TwitterException {
|
public void shareFunction() {
|
||||||
System.out.println("Sharing test");
|
log.logp(INFO, getClass().getName(), "shareFunction", "Sharing test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
page.clickMenuElement(2);
|
page.clickMenuElementPress();
|
||||||
|
|
||||||
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
||||||
pressPage.clickMenuElement(1);
|
pressPage.clickMenuElementMedia();
|
||||||
|
|
||||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||||
mediaLib.clickItemImage(0);
|
int elementNumber = 0;
|
||||||
|
mediaLib.clickItemImage(elementNumber);
|
||||||
|
|
||||||
mediaLib.clickSocialLink(2);
|
mediaLib.clickSocialLinkTwitter();
|
||||||
// String title = mediaLib.getAlbumTitle();
|
|
||||||
|
|
||||||
for (String winHandle : context.getDriver().getWindowHandles()) {
|
mediaLib.switchToTwitterPopup();
|
||||||
context.getDriver().switchTo().window(winHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
TwitterSharingPopup twitterSharingPopup = PageFactory.initElements(context.getDriver(), TwitterSharingPopup.class);
|
TwitterSharingPopup twitterSharingPopup = PageFactory.initElements(context.getDriver(), TwitterSharingPopup.class);
|
||||||
|
|
||||||
Assert.assertTrue(twitterSharingPopup.submitBtnPresent());
|
Assert.assertTrue(twitterSharingPopup.isSubmitBtnPresent());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
import PageHelpers.EventsPageHelper;
|
||||||
|
import PageHelpers.PurchasePageHelper;
|
||||||
|
import PageHelpers.SearchResultsPageHelper;
|
||||||
|
import PageHelpers.SubsidiariesPageHelper;
|
||||||
import Pages.*;
|
import Pages.*;
|
||||||
import context.ChromeContext;
|
import context.ChromeContext;
|
||||||
import context.Context;
|
import context.Context;
|
||||||
@ -8,13 +12,14 @@ import org.junit.Test;
|
|||||||
import org.openqa.selenium.Dimension;
|
import org.openqa.selenium.Dimension;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.logging.Logger;
|
||||||
import java.util.*;
|
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
|
||||||
public class FilterTests {
|
public class FilterTests {
|
||||||
private final static String APP_URL = "http://www.gazprom.ru/";
|
private final static String APP_URL = "http://www.gazprom.ru/";
|
||||||
|
private static java.util.logging.Logger log = Logger.getLogger(FilterTests.class.getName());
|
||||||
|
|
||||||
private static Context context;
|
private static Context context;
|
||||||
|
|
||||||
@ -33,8 +38,8 @@ public class FilterTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void simpleSearch() throws ParseException, InterruptedException {
|
public void simpleSearch() throws ParseException {
|
||||||
System.out.println("Simple search test");
|
log.logp(INFO, getClass().getName(), "simpleSearch", "Simple search test");
|
||||||
|
|
||||||
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
mainPage.clickSearchBtn();
|
mainPage.clickSearchBtn();
|
||||||
@ -44,86 +49,33 @@ public class FilterTests {
|
|||||||
mainPage.submitSearch();
|
mainPage.submitSearch();
|
||||||
|
|
||||||
SearchResultsPage searchResultsPage = PageFactory.initElements(context.getDriver(), SearchResultsPage.class);
|
SearchResultsPage searchResultsPage = PageFactory.initElements(context.getDriver(), SearchResultsPage.class);
|
||||||
boolean order = true;
|
SearchResultsPageHelper helper = new SearchResultsPageHelper(searchResultsPage);
|
||||||
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
|
||||||
Date datePrev = new Date();
|
|
||||||
boolean suitable = true;
|
|
||||||
|
|
||||||
Thread.sleep(2000);
|
Assert.assertTrue(helper.isSuitable(queryString));
|
||||||
|
|
||||||
for (int i = 0; i < searchResultsPage.getItemsCount(); i++) {
|
|
||||||
Date dateCur = format.parse(searchResultsPage.getItemsDate(i));
|
|
||||||
|
|
||||||
if(dateCur.after(datePrev)) {
|
|
||||||
System.out.println(dateCur +"!"+datePrev);
|
|
||||||
order = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!searchResultsPage.getItemsText(i).toLowerCase().contains(queryString)){
|
|
||||||
System.out.println("1"+searchResultsPage.getItemsText(i).toLowerCase());
|
|
||||||
System.out.println("2"+queryString);
|
|
||||||
suitable = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
datePrev= dateCur;
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertTrue(order&&suitable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sorting() {
|
public void sorting() {
|
||||||
System.out.println("Sorting test");
|
log.logp(INFO, getClass().getName(), "sorting", "Sorting test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
page.clickMenuElement(0);
|
page.clickMenuElementAbout();
|
||||||
|
|
||||||
AboutPage aboutPage = PageFactory.initElements(context.getDriver(), AboutPage.class);
|
AboutPage aboutPage = PageFactory.initElements(context.getDriver(), AboutPage.class);
|
||||||
aboutPage.clickMenuElement(4);
|
aboutPage.clickMenuElementSubsidaries();
|
||||||
|
|
||||||
SubsidiariesPage subsidiariesPage = PageFactory.initElements(context.getDriver(), SubsidiariesPage.class);
|
SubsidiariesPage subsidiariesPage = PageFactory.initElements(context.getDriver(), SubsidiariesPage.class);
|
||||||
subsidiariesPage.clickPercentFilter();
|
subsidiariesPage.clickPercentFilter();
|
||||||
|
|
||||||
boolean order = true;
|
SubsidiariesPageHelper helper = new SubsidiariesPageHelper(subsidiariesPage);
|
||||||
|
|
||||||
for (int i = 0; i < subsidiariesPage.getItemsPercent100Count(); i++) {
|
Assert.assertTrue(helper.isOrder());
|
||||||
float percent = subsidiariesPage.getPartOfItemPercent100(i);
|
|
||||||
// System.out.println(percent);
|
|
||||||
if(percent!= 100.0f){
|
|
||||||
System.out.println("!"+percent);
|
|
||||||
order = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < subsidiariesPage.getItemsPercentMore50Count(); i++) {
|
|
||||||
float percent = subsidiariesPage.getPartOfItemPercentMore50(i);
|
|
||||||
// System.out.println(percent);
|
|
||||||
if(percent<= 50.0f){
|
|
||||||
System.out.println("!"+percent);
|
|
||||||
order = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < subsidiariesPage.getItemsPercentLess50Count(); i++) {
|
|
||||||
float percent = subsidiariesPage.getPartOfItemPercentLess50(i);
|
|
||||||
// System.out.println(percent);
|
|
||||||
if(percent> 50.0f){
|
|
||||||
System.out.println("!"+percent);
|
|
||||||
order = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertTrue(order);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void filteredSearch() throws ParseException, InterruptedException {
|
public void filteredSearch() throws ParseException, InterruptedException {
|
||||||
System.out.println("Filtered search test");
|
log.logp(INFO, getClass().getName(), "filteredSearch", "Filtered search test");
|
||||||
|
|
||||||
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage mainPage = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
mainPage.clickSearchBtn();
|
mainPage.clickSearchBtn();
|
||||||
@ -133,109 +85,54 @@ public class FilterTests {
|
|||||||
mainPage.submitSearch();
|
mainPage.submitSearch();
|
||||||
|
|
||||||
SearchResultsPage searchResultsPage = PageFactory.initElements(context.getDriver(), SearchResultsPage.class);
|
SearchResultsPage searchResultsPage = PageFactory.initElements(context.getDriver(), SearchResultsPage.class);
|
||||||
|
SearchResultsPageHelper helper = new SearchResultsPageHelper(searchResultsPage);
|
||||||
|
|
||||||
searchResultsPage.setFilterOn();
|
searchResultsPage.setFilterOn();
|
||||||
searchResultsPage.selectYear(13);
|
searchResultsPage.selectYearByPosition(13);
|
||||||
|
|
||||||
int year = 2017;
|
int year = 2017;
|
||||||
Thread.sleep(2000);
|
|
||||||
|
|
||||||
boolean order = true;
|
Assert.assertTrue(helper.isSuitable(queryString,year));
|
||||||
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
|
||||||
|
|
||||||
Calendar calendar = new GregorianCalendar();
|
|
||||||
|
|
||||||
Date datePrev = new Date();
|
|
||||||
|
|
||||||
boolean suitable = true;
|
|
||||||
|
|
||||||
for (int i = 0; i < searchResultsPage.getItemsCount(); i++) {
|
|
||||||
Date dateCur = format.parse(searchResultsPage.getItemsDate(i));
|
|
||||||
|
|
||||||
if(dateCur.after(datePrev)) {
|
|
||||||
System.out.println(dateCur +"!"+datePrev);
|
|
||||||
order = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
calendar.setTime(dateCur);
|
|
||||||
|
|
||||||
if(!searchResultsPage.getItemsText(i).toLowerCase().contains(queryString)||calendar.get(Calendar.YEAR)!=year){
|
|
||||||
System.out.println("1"+searchResultsPage.getItemsText(i).toLowerCase().contains(queryString));
|
|
||||||
System.out.println("2"+calendar.get(Calendar.YEAR));
|
|
||||||
suitable = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertTrue(order&&suitable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void leftMenuFilter() throws ParseException {
|
public void leftMenuFilter() throws ParseException {
|
||||||
System.out.println("Filter by left menu test");
|
log.logp(INFO, getClass().getName(), "leftMenuFilter", "Filter by left menu test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
page.clickMenuElement(2);
|
page.clickMenuElementPress();
|
||||||
|
|
||||||
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
||||||
pressPage.clickMenuElement(0);
|
pressPage.clickMenuElementEventpage();
|
||||||
|
|
||||||
EventsPage eventsPage = PageFactory.initElements(context.getDriver(), EventsPage.class);
|
EventsPage eventsPage = PageFactory.initElements(context.getDriver(), EventsPage.class);
|
||||||
eventsPage.selectYear(1);
|
eventsPage.selectYearByPosition(1);
|
||||||
eventsPage.selectMonth(1);
|
eventsPage.selectMonthByPosition(1);
|
||||||
|
|
||||||
int year = 2017;
|
|
||||||
int month = 1;
|
int month = 1;
|
||||||
boolean suitable = true;
|
|
||||||
DateFormat format = new SimpleDateFormat("d MMMM, hh:mm");
|
|
||||||
Calendar calendar = new GregorianCalendar();
|
|
||||||
|
|
||||||
for (int i = 0; i < eventsPage.getResultsCount(); i++) {
|
EventsPageHelper helper = new EventsPageHelper(eventsPage);
|
||||||
Date dateCur = format.parse(eventsPage.getDateOfResult(i));
|
|
||||||
calendar.setTime(dateCur);
|
|
||||||
// System.out.println(calendar.get(Calendar.MONTH));
|
|
||||||
|
|
||||||
if(calendar.get(Calendar.MONTH)!=month){
|
Assert.assertTrue(helper.isSuitable(month));
|
||||||
suitable = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertTrue(suitable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pagination() throws InterruptedException {
|
public void pagination() {
|
||||||
System.out.println("Pagination test");
|
log.logp(INFO, getClass().getName(), "pagination", "Pagination test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
page.clickAdditionalMenuElement(1);
|
page.clickAdditionalMenuElementPurchase();
|
||||||
|
|
||||||
PurchasesPage purchasesPage = PageFactory.initElements(context.getDriver(), PurchasesPage.class);
|
PurchasesPage purchasesPage = PageFactory.initElements(context.getDriver(), PurchasesPage.class);
|
||||||
purchasesPage.clickMenuItem(2);
|
purchasesPage.clickMenuItemInWork();
|
||||||
// Thread.sleep(2000);
|
|
||||||
|
|
||||||
List<String> purchaseNumbers = new ArrayList();
|
|
||||||
for (int i = 0; i < purchasesPage.getItemsCount(); i++) {
|
|
||||||
purchaseNumbers.add(purchasesPage.getPurchaseNumber(i));
|
|
||||||
// System.out.println(purchasesPage.getPurchaseNumber(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
int pageNumber = 1;
|
int pageNumber = 1;
|
||||||
purchasesPage.clickPage(pageNumber);
|
purchasesPage.clickPage(pageNumber);
|
||||||
Thread.sleep(2000);
|
|
||||||
|
|
||||||
boolean turn = purchasesPage.isSelectedPage(pageNumber);
|
purchasesPage = PageFactory.initElements(context.getDriver(), PurchasesPage.class);
|
||||||
boolean found = false;
|
PurchasePageHelper helper = new PurchasePageHelper(purchasesPage);
|
||||||
|
|
||||||
for (int i = 0; i < purchasesPage.getItemsCount(); i++) {
|
|
||||||
if(purchaseNumbers.contains(purchasesPage.getPurchaseNumber(i)))
|
|
||||||
found=true;
|
|
||||||
|
|
||||||
// System.out.println(purchasesPage.getPurchaseNumber(i));
|
Assert.assertTrue(helper.waitAndCheckPageSelection(pageNumber));
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertTrue(turn&&!found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import PageHelpers.AlbumPageHelper;
|
||||||
|
import PageHelpers.MediaLibPageHelper;
|
||||||
import Pages.AlbumPage;
|
import Pages.AlbumPage;
|
||||||
import Pages.MediaLib;
|
import Pages.MediaLib;
|
||||||
import Pages.VideoPage;
|
import Pages.VideoPage;
|
||||||
@ -10,14 +12,15 @@ import org.junit.Test;
|
|||||||
import org.openqa.selenium.Dimension;
|
import org.openqa.selenium.Dimension;
|
||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.util.logging.Logger;
|
||||||
import java.util.Date;
|
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
|
||||||
public class MultimediaTests {
|
public class MultimediaTests {
|
||||||
|
|
||||||
private final static String APP_URL = "http://www.gazprom.ru/press/media/";
|
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;
|
private static Context context;
|
||||||
|
|
||||||
@ -36,117 +39,75 @@ public class MultimediaTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void albumList() throws ParseException, InterruptedException {
|
public void albumList() throws ParseException {
|
||||||
System.out.println("List of albums test");
|
log.logp(INFO, getClass().getName(), "albumList", "List of albums test");
|
||||||
|
|
||||||
|
|
||||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||||
mediaLib.selectMonth(1);
|
mediaLib.selectMonthByPosition(1);
|
||||||
// Thread.sleep(2000);
|
|
||||||
|
|
||||||
boolean order = true;
|
MediaLibPageHelper helper = new MediaLibPageHelper(mediaLib);
|
||||||
DateFormat format = new SimpleDateFormat("yyyy.M.d H:m");
|
Assert.assertTrue(helper.isOrder());
|
||||||
Date datePrev = format.parse(mediaLib.getDateOfItem(0));
|
|
||||||
|
|
||||||
for (int i = 1; i < mediaLib.getItemsCount(); i++) {
|
|
||||||
Date dateCur = format.parse(mediaLib.getDateOfItem(i));
|
|
||||||
if(dateCur.after(datePrev)) {
|
|
||||||
System.out.println(dateCur+"!"+datePrev);
|
|
||||||
order = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
datePrev = dateCur;
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertTrue(order);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void photoList() {
|
public void photoList() {
|
||||||
System.out.println("List of photos test");
|
log.logp(INFO, getClass().getName(), "photoList", "List of photos test");
|
||||||
|
|
||||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||||
int elementNumber = 0;
|
int elementNumber = 0;
|
||||||
String preview = mediaLib.getItemImageName(elementNumber);
|
String preview = mediaLib.getItemImageName(elementNumber);
|
||||||
mediaLib.clickItemImage(elementNumber);
|
mediaLib.clickItemImage(elementNumber);
|
||||||
System.out.println(preview);
|
|
||||||
|
|
||||||
AlbumPage albumPage = PageFactory.initElements(context.getDriver(), AlbumPage.class);
|
AlbumPage albumPage = PageFactory.initElements(context.getDriver(), AlbumPage.class);
|
||||||
|
AlbumPageHelper helper = new AlbumPageHelper(albumPage);
|
||||||
|
|
||||||
boolean containsPreview = false;
|
Assert.assertTrue(helper.containsPreview(preview));
|
||||||
for (int i = 0; i < albumPage.getImagesCount(); i++) {
|
|
||||||
String previewCur = albumPage.getImageName(i);
|
|
||||||
|
|
||||||
if(preview.equals(previewCur)) {
|
|
||||||
containsPreview = true;
|
|
||||||
System.out.println(previewCur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Assert.assertTrue(containsPreview);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void photosView() throws InterruptedException {
|
public void photosView() throws InterruptedException {
|
||||||
System.out.println("View of photos test");
|
log.logp(INFO, getClass().getName(), "photosView", "View of photos test");
|
||||||
|
|
||||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||||
mediaLib.clickItemImage(0);
|
mediaLib.clickItemImage(0);
|
||||||
|
|
||||||
AlbumPage albumPage = PageFactory.initElements(context.getDriver(), AlbumPage.class);
|
AlbumPage albumPage = PageFactory.initElements(context.getDriver(), AlbumPage.class);
|
||||||
albumPage.clickPhotoLink(0);
|
AlbumPageHelper helper = new AlbumPageHelper(albumPage);
|
||||||
|
helper.clickPhotoLink(0);
|
||||||
Thread.sleep(2000);
|
|
||||||
|
|
||||||
int elementNumber = 1;
|
int elementNumber = 1;
|
||||||
albumPage.clickPhotoPopup(elementNumber);
|
|
||||||
Assert.assertTrue(albumPage.isSelectedPhoto(elementNumber));
|
Assert.assertTrue(helper.isSelectedPhoto(elementNumber));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void videoList() throws ParseException, InterruptedException {
|
public void videoList() throws ParseException {
|
||||||
System.out.println("List of video test");
|
log.logp(INFO, getClass().getName(), "videoList", "List of video test");
|
||||||
|
|
||||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||||
mediaLib.clickVideoFilter();
|
mediaLib.clickVideoFilter();
|
||||||
|
|
||||||
// Thread.sleep(1000);
|
MediaLibPageHelper helper = new MediaLibPageHelper(mediaLib);
|
||||||
|
|
||||||
boolean order = true;
|
Assert.assertTrue(helper.isOrder());
|
||||||
DateFormat format = new SimpleDateFormat("yyyy.M.d H:m");
|
|
||||||
Date datePrev = format.parse(mediaLib.getDateOfItem(0));
|
|
||||||
for (int i = 1; i < mediaLib.getItemsCount(); i++) {
|
|
||||||
Date dateCur = format.parse(mediaLib.getDateOfItem(i));
|
|
||||||
System.out.println(dateCur);
|
|
||||||
if(dateCur.after(datePrev)) {
|
|
||||||
order = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertTrue(order);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void videoPage () throws InterruptedException {
|
public void videoPage () {
|
||||||
System.out.println("Page with video test");
|
log.logp(INFO, getClass().getName(), "videoPage", "Page with video test");
|
||||||
|
|
||||||
MediaLib mediaLibPhoto = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
MediaLib mediaLibPhoto = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||||
mediaLibPhoto.clickVideoFilter();
|
mediaLibPhoto.clickVideoFilter();
|
||||||
|
|
||||||
MediaLib mediaLibVideo = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
MediaLib mediaLibVideo = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||||
|
|
||||||
// Thread.sleep(3000);
|
mediaLibVideo.clickItem(0);
|
||||||
|
|
||||||
|
|
||||||
int elementNumber = 0;
|
|
||||||
String title = mediaLibVideo.getItemTitle(elementNumber);
|
|
||||||
mediaLibVideo.clickItem(elementNumber);
|
|
||||||
|
|
||||||
VideoPage videoPage = PageFactory.initElements(context.getDriver(), VideoPage.class);
|
VideoPage videoPage = PageFactory.initElements(context.getDriver(), VideoPage.class);
|
||||||
|
|
||||||
Assert.assertTrue(videoPage.getVideoTitle().equals(title));
|
Assert.assertTrue(videoPage.isVideoPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,10 +9,14 @@ import org.openqa.selenium.Dimension;
|
|||||||
import org.openqa.selenium.support.PageFactory;
|
import org.openqa.selenium.support.PageFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
|
||||||
public class NavigationTests {
|
public class NavigationTests {
|
||||||
|
|
||||||
private final static String APP_URL = "http://www.gazprom.ru/";
|
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;
|
private static Context context;
|
||||||
|
|
||||||
@ -32,78 +36,69 @@ public class NavigationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void topMenuTest() {
|
public void topMenuTest() {
|
||||||
System.out.println("Top menu test");
|
log.logp(INFO, getClass().getName(), "topMenuTest", "Top menu test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
int elementNumber = 2;
|
|
||||||
String title = page.getTitleMenuElement(elementNumber);
|
page.clickMenuElementPress();
|
||||||
page.clickMenuElement(elementNumber);
|
|
||||||
|
|
||||||
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
||||||
|
|
||||||
Assert.assertTrue(pressPage.getTitle().contains(title));
|
Assert.assertTrue(pressPage.isNewsPresent());
|
||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
public void subMenu(){
|
public void subMenu(){
|
||||||
System.out.println("Sub menu test");
|
log.logp(INFO, getClass().getName(), "subMenu", "Sub menu test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
page.clickMenuElement(0);
|
page.clickMenuElementPress();
|
||||||
|
|
||||||
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
||||||
int elementNumber = 1;
|
pressPage.clickMenuElementMedia();
|
||||||
String title = pressPage.getTitleMenuElement(elementNumber);
|
|
||||||
pressPage.clickMenuElement(elementNumber);
|
|
||||||
|
|
||||||
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
MediaLib mediaLib = PageFactory.initElements(context.getDriver(), MediaLib.class);
|
||||||
|
|
||||||
Assert.assertTrue(mediaLib.getTitle().contains(title));
|
Assert.assertTrue(mediaLib.isMediaListPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void hyperlinks(){
|
public void hyperlinks(){
|
||||||
System.out.println("Hyperlinks test");
|
log.logp(INFO, getClass().getName(), "hyperlinks", "Hyperlinks test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
page.clickMenuElement(0);
|
page.clickMenuElementAbout();
|
||||||
|
|
||||||
AboutPage aboutPage = PageFactory.initElements(context.getDriver(), AboutPage.class);
|
AboutPage aboutPage = PageFactory.initElements(context.getDriver(), AboutPage.class);
|
||||||
|
aboutPage.clickHyperlinksMiningElement();
|
||||||
int elementNumber = 0;
|
|
||||||
String title = aboutPage.getTextHyperlinksElement(elementNumber);
|
|
||||||
aboutPage.clickHyperlinksElement(elementNumber);
|
|
||||||
|
|
||||||
MiningPage miningPage = PageFactory.initElements(context.getDriver(), MiningPage.class);
|
MiningPage miningPage = PageFactory.initElements(context.getDriver(), MiningPage.class);
|
||||||
|
|
||||||
Assert.assertTrue(miningPage.getTitle().toLowerCase().contains(title));
|
Assert.assertTrue(miningPage.isMainContentPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sideMenu() {
|
public void sideMenu() {
|
||||||
System.out.println("Side menu test");
|
log.logp(INFO, getClass().getName(), "sideMenu", "Side menu test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
page.clickLayButton();
|
page.clickLayButton();
|
||||||
|
page.clickMarketingLayMenuElement();
|
||||||
int elementNumber = 3;
|
|
||||||
String title = page.getTitleLayMenuElement(elementNumber);
|
|
||||||
page.clickLayMenuElement(elementNumber);
|
|
||||||
|
|
||||||
MarketingPage marketingPage = PageFactory.initElements(context.getDriver(), MarketingPage.class);
|
MarketingPage marketingPage = PageFactory.initElements(context.getDriver(), MarketingPage.class);
|
||||||
|
|
||||||
Assert.assertTrue(marketingPage.getTitle().contains(title));
|
Assert.assertTrue(marketingPage.isMainContentPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void externalLinks() throws InterruptedException {
|
public void externalLinks() {
|
||||||
System.out.println("External links test");
|
log.logp(INFO, getClass().getName(), "externalLinks", "External links test");
|
||||||
|
|
||||||
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
MainPage page = PageFactory.initElements(context.getDriver(), MainPage.class);
|
||||||
page.clickExternalSitesBtn();
|
page.clickExternalSitesBtn();
|
||||||
|
|
||||||
int elementNumber = 0;
|
int elementNumber = 0;
|
||||||
String title = page.getTitleExternalLink(elementNumber);
|
String title = page.getTitleExternalLink(elementNumber);
|
||||||
page.clickExternalLink(elementNumber);
|
page.clickExternalLink(0);
|
||||||
|
|
||||||
ArrayList<String> tabs2 = new ArrayList<String> (context.getDriver().getWindowHandles());
|
ArrayList<String> tabs2 = new ArrayList<String> (context.getDriver().getWindowHandles());
|
||||||
context.getDriver().switchTo().window(tabs2.get(1));
|
context.getDriver().switchTo().window(tabs2.get(1));
|
||||||
|
68
Semenova/src/test/java/PageHelpers/AlbumPageHelper.java
Normal file
68
Semenova/src/test/java/PageHelpers/AlbumPageHelper.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package PageHelpers;
|
||||||
|
|
||||||
|
import Pages.AlbumPage;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
import static java.util.logging.Level.WARNING;
|
||||||
|
|
||||||
|
public class AlbumPageHelper {
|
||||||
|
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
||||||
|
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 InterruptedException {
|
||||||
|
|
||||||
|
int timeout = 10;
|
||||||
|
boolean isSelected = false;
|
||||||
|
for(int i=0;i<timeout;i++){
|
||||||
|
page.clickPhotoPopup();
|
||||||
|
isSelected = page.isSelectedPhoto(elementNumber);
|
||||||
|
|
||||||
|
if(isSelected) {
|
||||||
|
log.logp(INFO, getClass().getName(), "pagination", "time: " + i*200);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}
|
||||||
|
return isSelected;
|
||||||
|
}
|
||||||
|
private int tryLimit = 10;
|
||||||
|
public void clickPhotoLink(int elementNumber) {
|
||||||
|
|
||||||
|
boolean breakIt = true;
|
||||||
|
int attempt =0;
|
||||||
|
while (true&&attempt<tryLimit) {
|
||||||
|
attempt++;
|
||||||
|
breakIt = true;
|
||||||
|
try {
|
||||||
|
page.clickPhotoLink(elementNumber);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.logp(WARNING, getClass().getName(), "clickPhotoLink","Exception in clickPhotoLink method");
|
||||||
|
|
||||||
|
breakIt = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (breakIt) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
81
Semenova/src/test/java/PageHelpers/CalculatorPageHelper.java
Normal file
81
Semenova/src/test/java/PageHelpers/CalculatorPageHelper.java
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
package PageHelpers;
|
||||||
|
|
||||||
|
import Pages.CalculatorPage;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static java.lang.Math.round;
|
||||||
|
import static java.util.logging.Level.WARNING;
|
||||||
|
|
||||||
|
public class CalculatorPageHelper {
|
||||||
|
private static Logger log = Logger.getLogger(CalculatorPageHelper.class.getName());
|
||||||
|
|
||||||
|
private CalculatorPage page;
|
||||||
|
public CalculatorPageHelper(CalculatorPage page){
|
||||||
|
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){
|
||||||
|
|
||||||
|
waitForInputsPresent(page.getFromDateInput(),date);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private int tryLimit = 10;
|
||||||
|
public void waitForInputsPresent(WebElement element,String text){
|
||||||
|
boolean breakIt = true;
|
||||||
|
int attempt = 0;
|
||||||
|
while (true&&attempt<tryLimit) {
|
||||||
|
attempt++;
|
||||||
|
breakIt = true;
|
||||||
|
try {
|
||||||
|
element.clear();
|
||||||
|
element.sendKeys(text);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.logp(WARNING, getClass().getName(), "waitForInputsPresent","Exception in waitForInputsPresent method. Element: "+element);
|
||||||
|
|
||||||
|
breakIt = false;
|
||||||
|
}
|
||||||
|
if (breakIt) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void waitAndInsertToDate(String date){
|
||||||
|
|
||||||
|
waitForInputsPresent(page.getToDateInput(),date);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void waitAndInsertAmount(String amount){
|
||||||
|
|
||||||
|
waitForInputsPresent(page.getAmountInput(),amount);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
37
Semenova/src/test/java/PageHelpers/EventsPageHelper.java
Normal file
37
Semenova/src/test/java/PageHelpers/EventsPageHelper.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
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;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class EventsPageHelper {
|
||||||
|
|
||||||
|
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
||||||
|
private EventsPage page;
|
||||||
|
public EventsPageHelper(EventsPage page){
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
public boolean isSuitable(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;
|
||||||
|
}
|
||||||
|
}
|
19
Semenova/src/test/java/PageHelpers/FeedbackPageHelper.java
Normal file
19
Semenova/src/test/java/PageHelpers/FeedbackPageHelper.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package PageHelpers;
|
||||||
|
|
||||||
|
import Pages.FeedbackPage;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class FeedbackPageHelper {
|
||||||
|
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
||||||
|
private FeedbackPage page;
|
||||||
|
public FeedbackPageHelper(FeedbackPage page){
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
String successMessage = "Ваше сообщение отправлено.";
|
||||||
|
public boolean isReceiveSuccess(){
|
||||||
|
String output = page.getOutput();
|
||||||
|
return output.equals(successMessage);
|
||||||
|
}
|
||||||
|
}
|
50
Semenova/src/test/java/PageHelpers/MediaLibPageHelper.java
Normal file
50
Semenova/src/test/java/PageHelpers/MediaLibPageHelper.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
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 isOrder() 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;
|
||||||
|
}
|
||||||
|
public boolean order() 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)) {
|
||||||
|
order = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
}
|
49
Semenova/src/test/java/PageHelpers/PurchasePageHelper.java
Normal file
49
Semenova/src/test/java/PageHelpers/PurchasePageHelper.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package PageHelpers;
|
||||||
|
|
||||||
|
import Pages.PurchasesPage;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
import static java.util.logging.Level.WARNING;
|
||||||
|
|
||||||
|
public class PurchasePageHelper {
|
||||||
|
|
||||||
|
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
||||||
|
private PurchasesPage page;
|
||||||
|
public PurchasePageHelper(PurchasesPage page){
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int tryLimit = 10;
|
||||||
|
public boolean waitAndCheckPageSelection(int pageNumber){
|
||||||
|
boolean breakIt = true;
|
||||||
|
boolean turn = false;
|
||||||
|
int attempt = 0;
|
||||||
|
while (true&&attempt<tryLimit) {
|
||||||
|
attempt++;
|
||||||
|
breakIt = true;
|
||||||
|
try {
|
||||||
|
int timeout = 10;
|
||||||
|
for(int i=0;i<timeout;i++){
|
||||||
|
turn = page.isSelectedPage(pageNumber);
|
||||||
|
if(turn) {
|
||||||
|
log.logp(INFO, getClass().getName(), "pagination", "time: " + i*200);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.logp(WARNING, getClass().getName(), "waitAndCheckPageSelection","Exception in waitAndCheckPageSelection method");
|
||||||
|
|
||||||
|
breakIt = false;
|
||||||
|
}
|
||||||
|
if (breakIt) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return turn;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
137
Semenova/src/test/java/PageHelpers/SearchResultsPageHelper.java
Normal file
137
Semenova/src/test/java/PageHelpers/SearchResultsPageHelper.java
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
package PageHelpers;
|
||||||
|
|
||||||
|
import Pages.SearchResultsPage;
|
||||||
|
|
||||||
|
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.INFO;
|
||||||
|
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 isSuitable(String queryString) throws ParseException {
|
||||||
|
|
||||||
|
boolean order = true;
|
||||||
|
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
||||||
|
Date datePrev = new Date();
|
||||||
|
boolean suitable = 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(!waitAndGetItemsText(i).toLowerCase().contains(queryString)){
|
||||||
|
log.logp(WARNING, getClass().getName(), "simpleSearch", "'" + waitAndGetItemsText(i)+"' is not suitable for '"+queryString+"'");
|
||||||
|
suitable = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
datePrev= dateCur;
|
||||||
|
}
|
||||||
|
return order&&suitable;
|
||||||
|
|
||||||
|
}
|
||||||
|
public boolean isSuitable(String queryString,int year) throws InterruptedException, ParseException {
|
||||||
|
boolean order = true;
|
||||||
|
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
||||||
|
Calendar calendar = new GregorianCalendar();
|
||||||
|
Date datePrev = new Date();
|
||||||
|
|
||||||
|
boolean suitable = true;
|
||||||
|
|
||||||
|
for (int i = 0; i < page.getItemsCount(); i++) {
|
||||||
|
Date dateCur = new Date();
|
||||||
|
|
||||||
|
int timeout = 10;
|
||||||
|
boolean isSuitableElement = false;
|
||||||
|
for(int k=0;k<timeout;k++){
|
||||||
|
dateCur = format.parse(waitAngGetItemsDate(i));
|
||||||
|
calendar.setTime(dateCur);
|
||||||
|
|
||||||
|
isSuitableElement = matchedByYearAndQuery(waitAndGetItemsText(i),queryString,calendar,year);
|
||||||
|
|
||||||
|
if(isSuitableElement) {
|
||||||
|
log.logp(INFO, getClass().getName(), "filteredSearch", "time: " + k*200);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}
|
||||||
|
if(dateCur.after(datePrev)) {
|
||||||
|
log.logp(WARNING, getClass().getName(), "filteredSearch", "Date current: '"+dateCur +"', Date previous: '"+datePrev+"'");
|
||||||
|
order = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(!isSuitableElement){
|
||||||
|
log.logp(WARNING, getClass().getName(), "filteredSearch",
|
||||||
|
"'" + waitAndGetItemsText(i)+"' is not suitable for '"+queryString+"' or '"+calendar.get(Calendar.YEAR)+"' != '"+year+"'");
|
||||||
|
suitable = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return order&&suitable;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean matchedByYearAndQuery(String itemText, String query, Calendar calendar, int year){
|
||||||
|
return itemText.toLowerCase().contains(query)&&calendar.get(Calendar.YEAR)==year;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int tryLimit = 10;
|
||||||
|
public String waitAndGetItemsText(int itemNumber){
|
||||||
|
String text="";
|
||||||
|
boolean breakIt = true;
|
||||||
|
int attempt =0;
|
||||||
|
while (true&&attempt<tryLimit) {
|
||||||
|
attempt++;
|
||||||
|
breakIt = true;
|
||||||
|
try {
|
||||||
|
text=page.getItemsText(itemNumber);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.logp(WARNING, getClass().getName(), "waitAndGetItemsText","Exception in waitAndGetItemsText method");
|
||||||
|
|
||||||
|
breakIt = false;
|
||||||
|
}
|
||||||
|
if (breakIt) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
public String waitAngGetItemsDate(int itemNumber){
|
||||||
|
String date="";
|
||||||
|
boolean breakIt = true;
|
||||||
|
int attempt =0;
|
||||||
|
while (true&&attempt<tryLimit) {
|
||||||
|
attempt++;
|
||||||
|
breakIt = true;
|
||||||
|
try {
|
||||||
|
date=page.getItemsDate(itemNumber);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.logp(WARNING, getClass().getName(), "waitAngGetItemsDate","Exception in waitAngGetItemsDate method");
|
||||||
|
|
||||||
|
breakIt = false;
|
||||||
|
}
|
||||||
|
if (breakIt) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package PageHelpers;
|
||||||
|
|
||||||
|
import Pages.SubsidiariesPage;
|
||||||
|
|
||||||
|
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() {
|
||||||
|
|
||||||
|
boolean order = true;
|
||||||
|
|
||||||
|
for (int i = 0; i < page.getItemsPercent100Count(); i++) {
|
||||||
|
float percent = page.getPartOfItemPercent100(i);
|
||||||
|
if(percent!= 100.0f){
|
||||||
|
log.logp(WARNING, getClass().getName(), "sorting", "'" + percent+"' is not '100'");
|
||||||
|
order = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < page.getItemsPercentMore50Count(); i++) {
|
||||||
|
float percent = page.getPartOfItemPercentMore50(i);
|
||||||
|
if(percent<= 50.0f){
|
||||||
|
log.logp(WARNING, getClass().getName(), "sorting", "'" + percent+"' is not more than '50'");
|
||||||
|
order = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < page.getItemsPercentLess50Count(); i++) {
|
||||||
|
float percent = page.getPartOfItemPercentLess50(i);
|
||||||
|
if(percent> 50.0f){
|
||||||
|
log.logp(WARNING, getClass().getName(), "sorting", "'" + percent+"' is not less than '50'");
|
||||||
|
order = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return order;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,6 @@ package Pages;
|
|||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -16,20 +15,19 @@ public class AboutPage {
|
|||||||
@FindBy(css = ".subnavigation li")
|
@FindBy(css = ".subnavigation li")
|
||||||
private List<WebElement> subMenuElements;
|
private List<WebElement> subMenuElements;
|
||||||
|
|
||||||
|
private static int subsidariesPageMenuElementNumber = 4;
|
||||||
|
private static int miningHyperLinkNumber = 0;
|
||||||
|
|
||||||
public AboutPage(WebDriver driver) {
|
public AboutPage(WebDriver driver) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickHyperlinksElement(int elementNumber){
|
public void clickHyperlinksMiningElement(){
|
||||||
hyperlinkElements.get(elementNumber).click();
|
hyperlinkElements.get(miningHyperLinkNumber).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTextHyperlinksElement(int elementNumber){
|
public void clickMenuElementSubsidaries(){
|
||||||
return hyperlinkElements.get(elementNumber).getText();
|
subMenuElements.get(subsidariesPageMenuElementNumber).click();
|
||||||
}
|
|
||||||
|
|
||||||
public void clickMenuElement(int elementNumber){
|
|
||||||
subMenuElements.get(elementNumber).click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,36 @@
|
|||||||
package Pages;
|
package Pages;
|
||||||
|
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.JavascriptExecutor;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
|
import org.openqa.selenium.WebDriverException;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static java.util.logging.Level.INFO;
|
||||||
|
|
||||||
public class AlbumPage {
|
public class AlbumPage {
|
||||||
|
|
||||||
private WebDriverWait wait;
|
private WebDriverWait wait;
|
||||||
private WebDriver driver;
|
private WebDriver driver;
|
||||||
|
private static java.util.logging.Logger log = Logger.getLogger(AlbumPage.class.getName());
|
||||||
|
|
||||||
@FindBy(css = ".media__list .media__item img")
|
@FindBy(css = ".media__list .media__item img")
|
||||||
private List<WebElement> albumImages;
|
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")
|
@FindBy(css = ".media__popup__thumbs .media__popup__thumb")
|
||||||
private List<WebElement> photosPopup;
|
private List<WebElement> photosPopup;
|
||||||
|
|
||||||
|
@FindBy(css = ".media__popup__thumbs .media__popup__thumb:not(.media__popup__thumb--selected)")
|
||||||
|
private WebElement notSelectedThump;
|
||||||
|
|
||||||
public AlbumPage(WebDriver driver) {
|
public AlbumPage(WebDriver driver) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
wait = new WebDriverWait(driver,30,500);
|
wait = new WebDriverWait(driver,30,500);
|
||||||
@ -39,13 +50,20 @@ public class AlbumPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clickPhotoLink(int elementNumber) {
|
public void clickPhotoLink(int elementNumber) {
|
||||||
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("media__item")));
|
wait.until(ExpectedConditions.visibilityOf(albumImages.get(elementNumber)));
|
||||||
albumImages.get(elementNumber).click();
|
albumImages.get(elementNumber).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickPhotoPopup(int elementNumber) {
|
public void clickPhotoPopup() {
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(photosPopup.get(elementNumber)));
|
try{
|
||||||
photosPopup.get(elementNumber).click();
|
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){
|
public boolean isSelectedPhoto(int elementNumber){
|
||||||
|
@ -57,9 +57,11 @@ public class CalculatorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void switchToCalcFrame(){
|
public void switchToCalcFrame(){
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(ruCalcFrame));
|
wait.until(ExpectedConditions.visibilityOf(ruCalcFrame));
|
||||||
driver.switchTo().frame(ruCalcFrame);
|
driver.switchTo().frame(ruCalcFrame);
|
||||||
|
wait.until(ExpectedConditions.visibilityOf(chartFrame));
|
||||||
driver.switchTo().frame(chartFrame);
|
driver.switchTo().frame(chartFrame);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickCalcBtn(){
|
public void clickCalcBtn(){
|
||||||
@ -68,63 +70,49 @@ public class CalculatorPage {
|
|||||||
|
|
||||||
public double getStartPrice(){
|
public double getStartPrice(){
|
||||||
|
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(startPrice));
|
|
||||||
|
|
||||||
String tmp = startPrice.getText();
|
String tmp = startPrice.getText();
|
||||||
tmp = tmp.substring(0,tmp.lastIndexOf(" ")+1);
|
tmp = tmp.substring(0,tmp.lastIndexOf(" ")+1);
|
||||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getEndPrice(){
|
public double getEndPrice(){
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(endPrice));
|
|
||||||
String tmp = endPrice.getText();
|
String tmp = endPrice.getText();
|
||||||
tmp = tmp.substring(0,tmp.lastIndexOf(" ")+1);
|
tmp = tmp.substring(0,tmp.lastIndexOf(" ")+1);
|
||||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getReInvPrice(){
|
public double getReInvPrice(){
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(reInvPrice));
|
|
||||||
String tmp = reInvPrice.getText();
|
String tmp = reInvPrice.getText();
|
||||||
tmp = tmp.substring(0,tmp.lastIndexOf(" ")+1);
|
tmp = tmp.substring(0,tmp.lastIndexOf(" ")+1);
|
||||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getChangePrice(){
|
public double getChangePrice(){
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(changePrice));
|
|
||||||
String tmp = changePrice.getText();
|
String tmp = changePrice.getText();
|
||||||
tmp = tmp.substring(0,tmp.lastIndexOf("%"));
|
tmp = tmp.substring(0,tmp.lastIndexOf("%"));
|
||||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getChangePriceRe(){
|
public double getChangePriceRe(){
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(changePriceRe));
|
|
||||||
String tmp = changePriceRe.getText();
|
String tmp = changePriceRe.getText();
|
||||||
tmp = tmp.substring(0,tmp.lastIndexOf("%"));
|
tmp = tmp.substring(0,tmp.lastIndexOf("%"));
|
||||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getIncome(){
|
public double getIncome(){
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(income));
|
|
||||||
String tmp = income.getText();
|
String tmp = income.getText();
|
||||||
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
return Double.parseDouble(tmp.replace(",",".").replace(" ",""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertFromDate(String text){
|
public WebElement getFromDateInput() {
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(fromDateInput));
|
return fromDateInput;
|
||||||
fromDateInput.clear();
|
|
||||||
fromDateInput.sendKeys(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertToDate(String text){
|
public WebElement getToDateInput() {
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(toDateInput));
|
return toDateInput;
|
||||||
toDateInput.clear();
|
|
||||||
toDateInput.sendKeys(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertAmount(String text){
|
public WebElement getAmountInput() {
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(amountInput));
|
return amountInput;
|
||||||
amountInput.clear();
|
|
||||||
amountInput.sendKeys(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,11 @@ public class EventsPage {
|
|||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectYear(int itemNumber){
|
public void selectYearByPosition(int itemNumber){
|
||||||
yearsFilter.get(itemNumber).click();
|
yearsFilter.get(itemNumber).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectMonth(int itemNumber){
|
public void selectMonthByPosition(int itemNumber){
|
||||||
monthFilter.get(itemNumber).click();
|
monthFilter.get(itemNumber).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,4 @@ public class ForShareholders {
|
|||||||
downloadLinks.get(elementNumber).click();
|
downloadLinks.get(elementNumber).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickMenuElement(int elementNumber){
|
|
||||||
subMenuElements.get(elementNumber).click();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -37,31 +37,35 @@ public class MainPage {
|
|||||||
@FindBy(css = ".additional_top_navigation a")
|
@FindBy(css = ".additional_top_navigation a")
|
||||||
private List<WebElement> additionalMenu;
|
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) {
|
public MainPage(WebDriver driver) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
wait = new WebDriverWait(driver,30,500);
|
wait = new WebDriverWait(driver,30,500);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickMenuElement(int elementNumber){
|
public void clickMenuElementShareholder(){
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements.get(shareholdersPageMenuElementNumber)));
|
||||||
menuElements.get(elementNumber).click();
|
menuElements.get(shareholdersPageMenuElementNumber).click();
|
||||||
}
|
}
|
||||||
|
public void clickMenuElementAbout(){
|
||||||
public String getTitleMenuElement(int elementNumber){
|
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements.get(shareholdersPageMenuElementNumber)));
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
menuElements.get(aboutPageMenuElementNumber).click();
|
||||||
return menuElements.get(elementNumber).getText();
|
}
|
||||||
|
public void clickMenuElementPress(){
|
||||||
|
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements.get(shareholdersPageMenuElementNumber)));
|
||||||
|
menuElements.get(pressPageMenuElementNumber).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickLayButton(){
|
public void clickLayButton(){
|
||||||
layButton.click();
|
layButton.click();
|
||||||
}
|
}
|
||||||
|
public void clickMarketingLayMenuElement(){
|
||||||
public void clickLayMenuElement(int elementNumber){
|
layMenuElements.get(marketingPageMenuElementNumber).click();
|
||||||
layMenuElements.get(elementNumber).click();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitleLayMenuElement(int elementNumber){
|
|
||||||
return layMenuElements.get(elementNumber).getText();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickExternalSitesBtn(){
|
public void clickExternalSitesBtn(){
|
||||||
@ -84,6 +88,7 @@ public class MainPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void insertSearchText(String text){
|
public void insertSearchText(String text){
|
||||||
|
wait.until(ExpectedConditions.visibilityOf(searchField));
|
||||||
searchField.sendKeys(text);
|
searchField.sendKeys(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +96,7 @@ public class MainPage {
|
|||||||
searchField.sendKeys(Keys.RETURN);
|
searchField.sendKeys(Keys.RETURN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickAdditionalMenuElement(int elementNumber){
|
public void clickAdditionalMenuElementPurchase(){
|
||||||
additionalMenu.get(elementNumber).click();
|
additionalMenu.get(purchasePageMenuElementNumber).click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
package Pages;
|
package Pages;
|
||||||
|
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
import org.openqa.selenium.WebElement;
|
||||||
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
public class MarketingPage {
|
public class MarketingPage {
|
||||||
private WebDriver driver;
|
private WebDriver driver;
|
||||||
|
|
||||||
|
@FindBy(css = ".main-content")
|
||||||
|
private WebElement mainContentElement;
|
||||||
|
|
||||||
|
|
||||||
public MarketingPage(WebDriver driver) {
|
public MarketingPage(WebDriver driver) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle(){
|
public boolean isMainContentPresent(){
|
||||||
return driver.getTitle();
|
return mainContentElement.isDisplayed();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package Pages;
|
package Pages;
|
||||||
|
|
||||||
import org.openqa.selenium.By;
|
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
@ -37,15 +36,16 @@ public class MediaLib {
|
|||||||
@FindBy(css = ".h1--semi-margin-bottom")
|
@FindBy(css = ".h1--semi-margin-bottom")
|
||||||
private WebElement albumTitle;
|
private WebElement albumTitle;
|
||||||
|
|
||||||
|
@FindBy(css = ".media__list ")
|
||||||
|
private WebElement mediaListElement;
|
||||||
|
|
||||||
|
private static int socialLinkTwitter = 2;
|
||||||
|
|
||||||
public MediaLib(WebDriver driver) {
|
public MediaLib(WebDriver driver) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
wait = new WebDriverWait(driver,10,500);
|
wait = new WebDriverWait(driver,10,500);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle(){
|
|
||||||
return driver.getTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDateOfItem(int elementNumber){
|
public String getDateOfItem(int elementNumber){
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(itemsDates.get(elementNumber)));
|
wait.until(ExpectedConditions.visibilityOfAllElements(itemsDates.get(elementNumber)));
|
||||||
return itemsDates.get(elementNumber).getAttribute("value");
|
return itemsDates.get(elementNumber).getAttribute("value");
|
||||||
@ -56,11 +56,12 @@ public class MediaLib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clickItemImage(int elementNumber){
|
public void clickItemImage(int elementNumber){
|
||||||
wait.until(ExpectedConditions.visibilityOfElementLocated(By.className("media__item")));
|
wait.until(ExpectedConditions.visibilityOf( albumsImages.get(elementNumber)));
|
||||||
albumsImages.get(elementNumber).click();
|
albumsImages.get(elementNumber).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getItemImageName(int elementNumber){
|
public String getItemImageName(int elementNumber){
|
||||||
|
wait.until(ExpectedConditions.visibilityOf(albumsImages.get(elementNumber)));
|
||||||
String preview = albumsImages.get(elementNumber).getAttribute("src");
|
String preview = albumsImages.get(elementNumber).getAttribute("src");
|
||||||
preview = preview.substring(preview.lastIndexOf("_")+1);
|
preview = preview.substring(preview.lastIndexOf("_")+1);
|
||||||
|
|
||||||
@ -71,25 +72,26 @@ public class MediaLib {
|
|||||||
contentFilter.get(0).click();
|
contentFilter.get(0).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getItemTitle(int elementNumber){
|
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(itemsTitles.get(elementNumber)));
|
|
||||||
return itemsTitles.get(elementNumber).getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clickItem(int elementNumber){
|
public void clickItem(int elementNumber){
|
||||||
itemsLinks.get(elementNumber).click();
|
itemsLinks.get(elementNumber).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectMonth(int itemNumber){
|
public void selectMonthByPosition(int itemNumber){
|
||||||
monthFilter.get(itemNumber).click();
|
monthFilter.get(itemNumber).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickSocialLink(int itemNumber){
|
public void clickSocialLinkTwitter(){
|
||||||
socialLinks.get(itemNumber).click();
|
socialLinks.get(socialLinkTwitter).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAlbumTitle(){
|
public void switchToTwitterPopup(){
|
||||||
return albumTitle.getText();
|
|
||||||
|
for (String winHandle : driver.getWindowHandles()) {
|
||||||
|
driver.switchTo().window(winHandle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMediaListPresent(){
|
||||||
|
return mediaListElement.isDisplayed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
package Pages;
|
package Pages;
|
||||||
|
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
import org.openqa.selenium.WebElement;
|
||||||
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
public class MiningPage {
|
public class MiningPage {
|
||||||
private WebDriver driver;
|
private WebDriver driver;
|
||||||
|
|
||||||
|
@FindBy(css = ".main-content")
|
||||||
|
private WebElement mainContentElement;
|
||||||
|
|
||||||
|
|
||||||
public MiningPage(WebDriver driver) {
|
public MiningPage(WebDriver driver) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle(){
|
public boolean isMainContentPresent(){
|
||||||
return driver.getTitle();
|
return mainContentElement.isDisplayed();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,25 +15,33 @@ public class PressPage {
|
|||||||
@FindBy(css = ".subnavigation li")
|
@FindBy(css = ".subnavigation li")
|
||||||
private List<WebElement> menuElements;
|
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) {
|
public PressPage(WebDriver driver) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
wait = new WebDriverWait(driver,30,500);
|
wait = new WebDriverWait(driver,30,500);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle(){
|
public void clickMenuElementJournal(){
|
||||||
return driver.getTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clickMenuElement(int elementNumber){
|
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
||||||
menuElements.get(elementNumber).click();
|
menuElements.get(journalPageMenuElementNumber).click();
|
||||||
}
|
}
|
||||||
|
public void clickMenuElementEventpage(){
|
||||||
public String getTitleMenuElement(int elementNumber){
|
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
||||||
return menuElements.get(elementNumber).getText();
|
menuElements.get(eventPageMenuElementNumber).click();
|
||||||
|
}
|
||||||
|
public void clickMenuElementMedia(){
|
||||||
|
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
||||||
|
menuElements.get(mediaPageMenuElementNumber).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isNewsPresent(){
|
||||||
|
return newsElement.isDisplayed();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package Pages;
|
package Pages;
|
||||||
|
|
||||||
import org.openqa.selenium.By;
|
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -25,21 +23,19 @@ public class PurchasesPage {
|
|||||||
@FindBy(css = ".dataTables_paginate span")
|
@FindBy(css = ".dataTables_paginate span")
|
||||||
private List<WebElement> paginationElements;
|
private List<WebElement> paginationElements;
|
||||||
|
|
||||||
|
private static int feedbackMenuElementNumber = 10;
|
||||||
|
private static int inWorkPurchaseMenuElementNumber = 2;
|
||||||
|
|
||||||
public PurchasesPage(WebDriver driver) {
|
public PurchasesPage(WebDriver driver) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
wait = new WebDriverWait(driver,30,500);
|
wait = new WebDriverWait(driver,30,500);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickMenuItem(int itemNumber){
|
public void clickMenuItemInWork(){
|
||||||
menuElements.get(itemNumber).click();
|
menuElements.get(inWorkPurchaseMenuElementNumber).click();
|
||||||
}
|
}
|
||||||
|
public void clickMenuItemFeedback(){
|
||||||
public String getPurchaseNumber(int itemNumber){
|
menuElements.get(feedbackMenuElementNumber).click();
|
||||||
return purchasesNumbers.get(itemNumber).getText();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemsCount(){
|
|
||||||
return searchResults.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickPage(int pageNumber){
|
public void clickPage(int pageNumber){
|
||||||
@ -47,6 +43,7 @@ public class PurchasesPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSelectedPage(int pageNumber){
|
public boolean isSelectedPage(int pageNumber){
|
||||||
return paginationElements.get(pageNumber).getAttribute("class").equals("paginate_active");
|
boolean isSelect = paginationElements.get(pageNumber).getAttribute("class").equals("paginate_active");
|
||||||
|
return isSelect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package Pages;
|
|||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,6 +30,7 @@ public class SearchResultsPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getItemsText(int itemNumber){
|
public String getItemsText(int itemNumber){
|
||||||
|
|
||||||
return searchResultsTexts.get(itemNumber).getText();
|
return searchResultsTexts.get(itemNumber).getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,17 +38,19 @@ public class SearchResultsPage {
|
|||||||
return searchResultsDates.get(itemNumber).getAttribute("value");
|
return searchResultsDates.get(itemNumber).getAttribute("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getItemsCount(){
|
public int getItemsCount() {
|
||||||
|
int size = searchResultsTexts.size();
|
||||||
|
System.out.println(size);
|
||||||
|
return size;
|
||||||
|
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(searchResultsTexts));
|
|
||||||
return searchResultsTexts.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilterOn(){
|
public void setFilterOn(){
|
||||||
filterOn.click();
|
filterOn.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectYear(int itemNumber){
|
public void selectYearByPosition(int itemNumber){
|
||||||
yearsFilter.get(itemNumber).click();
|
yearsFilter.get(itemNumber).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package Pages;
|
|||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -20,19 +20,7 @@ public class TwitterSharingPopup {
|
|||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertUsername(String username){
|
public boolean isSubmitBtnPresent(){
|
||||||
usernameInput.sendKeys(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void insertPassword(String password){
|
|
||||||
passInput.sendKeys(password);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clickSubmit(){
|
|
||||||
submitBtn.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean submitBtnPresent(){
|
|
||||||
return submitBtn.isDisplayed();
|
return submitBtn.isDisplayed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package Pages;
|
|||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -20,14 +19,15 @@ public class VideoPage {
|
|||||||
@FindBy(css = ".media_filter h1")
|
@FindBy(css = ".media_filter h1")
|
||||||
private WebElement videoTitle;
|
private WebElement videoTitle;
|
||||||
|
|
||||||
|
@FindBy(css = ".media__iframe")
|
||||||
|
private WebElement videoElement;
|
||||||
|
|
||||||
public VideoPage(WebDriver driver) {
|
public VideoPage(WebDriver driver) {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
}
|
}
|
||||||
public String getTitle(){
|
|
||||||
return driver.getTitle();
|
public boolean isVideoPresent(){
|
||||||
|
return videoElement.isDisplayed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVideoTitle(){
|
|
||||||
return videoTitle.getText();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,12 @@ public class ChromeContext extends Context {
|
|||||||
protected void createDriver() {
|
protected void createDriver() {
|
||||||
ChromeOptions options = new ChromeOptions();
|
ChromeOptions options = new ChromeOptions();
|
||||||
Map<String, Object> prefs = new HashMap<String, Object>();
|
Map<String, Object> prefs = new HashMap<String, Object>();
|
||||||
prefs.put("plugins.always_open_pdf_externally", true);
|
|
||||||
// tmpPath = System.getProperty("java.io.tmpdir");
|
|
||||||
|
|
||||||
tmpPath = System.getProperty("user.dir") + "/src/main/resources/downloads/";
|
tmpPath = System.getProperty("user.dir") + "/src/main/resources/downloads/";
|
||||||
|
|
||||||
prefs.put("download.default_directory", tmpPath);
|
prefs.put("download.default_directory", tmpPath);
|
||||||
|
prefs.put("plugins.always_open_pdf_externally", true);
|
||||||
|
|
||||||
options.setExperimentalOption("prefs",prefs);
|
options.setExperimentalOption("prefs",prefs);
|
||||||
|
|
||||||
driver = new ChromeDriver(options);
|
driver = new ChromeDriver(options);
|
||||||
|
Loading…
Reference in New Issue
Block a user