Semenova #2
@ -35,7 +35,7 @@ public class CalculatorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void countInvestor() throws InterruptedException {
|
public void countInvestor() throws InterruptedException, NoSuchMethodException {
|
||||||
log.logp(INFO, getClass().getName(), "countInvestor", "Investor's count test");
|
log.logp(INFO, getClass().getName(), "countInvestor", "Investor's count test");
|
||||||
|
|
||||||
CalculatorPage calculatorPage = PageFactory.initElements(context.getDriver(), CalculatorPage.class);
|
CalculatorPage calculatorPage = PageFactory.initElements(context.getDriver(), CalculatorPage.class);
|
||||||
@ -51,7 +51,6 @@ public class CalculatorTest {
|
|||||||
|
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
|
|
||||||
|
|
||||||
Assert.assertTrue(calculatorPageHelper.isCalculationRight());
|
Assert.assertTrue(calculatorPageHelper.isCalculationRight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ 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 final static String APP_URL = "http://www.gazprom.ru/tenders/";
|
||||||
private static java.util.logging.Logger log = Logger.getLogger(FilterTests.class.getName());
|
private static java.util.logging.Logger log = Logger.getLogger(FilterTests.class.getName());
|
||||||
|
|
||||||
private static Context context;
|
private static Context context;
|
||||||
@ -38,7 +39,7 @@ public class FilterTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void simpleSearch() throws ParseException {
|
public void simpleSearch() throws ParseException, NoSuchMethodException {
|
||||||
log.logp(INFO, getClass().getName(), "simpleSearch", "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);
|
||||||
@ -51,12 +52,12 @@ public class FilterTests {
|
|||||||
SearchResultsPage searchResultsPage = PageFactory.initElements(context.getDriver(), SearchResultsPage.class);
|
SearchResultsPage searchResultsPage = PageFactory.initElements(context.getDriver(), SearchResultsPage.class);
|
||||||
SearchResultsPageHelper helper = new SearchResultsPageHelper(searchResultsPage);
|
SearchResultsPageHelper helper = new SearchResultsPageHelper(searchResultsPage);
|
||||||
|
|
||||||
Assert.assertTrue(helper.isSuitable(queryString));
|
Assert.assertTrue(helper.searchResultsMatchQueryAndInOrder(queryString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sorting() {
|
public void sorting() throws Exception {
|
||||||
log.logp(INFO, getClass().getName(), "sorting", "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);
|
||||||
@ -74,7 +75,7 @@ public class FilterTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void filteredSearch() throws ParseException, InterruptedException {
|
public void filteredSearch() throws ParseException, InterruptedException, NoSuchMethodException {
|
||||||
log.logp(INFO, getClass().getName(), "filteredSearch", "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);
|
||||||
@ -92,7 +93,7 @@ public class FilterTests {
|
|||||||
|
|
||||||
int year = 2017;
|
int year = 2017;
|
||||||
|
|
||||||
Assert.assertTrue(helper.isSuitable(queryString,year));
|
Assert.assertTrue(helper.searchResultsMatchQueryYearAndInOrder(queryString,year));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -103,7 +104,7 @@ public class FilterTests {
|
|||||||
page.clickMenuElementPress();
|
page.clickMenuElementPress();
|
||||||
|
|
||||||
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
PressPage pressPage = PageFactory.initElements(context.getDriver(), PressPage.class);
|
||||||
pressPage.clickMenuElementEventpage();
|
pressPage.clickMenuElementEventPage();
|
||||||
|
|
||||||
EventsPage eventsPage = PageFactory.initElements(context.getDriver(), EventsPage.class);
|
EventsPage eventsPage = PageFactory.initElements(context.getDriver(), EventsPage.class);
|
||||||
eventsPage.selectYearByPosition(1);
|
eventsPage.selectYearByPosition(1);
|
||||||
@ -113,11 +114,11 @@ public class FilterTests {
|
|||||||
|
|
||||||
EventsPageHelper helper = new EventsPageHelper(eventsPage);
|
EventsPageHelper helper = new EventsPageHelper(eventsPage);
|
||||||
|
|
||||||
Assert.assertTrue(helper.isSuitable(month));
|
Assert.assertTrue(helper.eventsMatchByMonth(month));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void pagination() {
|
public void pagination() throws InterruptedException, NoSuchMethodException {
|
||||||
log.logp(INFO, getClass().getName(), "pagination", "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);
|
||||||
|
@ -46,7 +46,7 @@ public class MultimediaTests {
|
|||||||
mediaLib.selectMonthByPosition(1);
|
mediaLib.selectMonthByPosition(1);
|
||||||
|
|
||||||
MediaLibPageHelper helper = new MediaLibPageHelper(mediaLib);
|
MediaLibPageHelper helper = new MediaLibPageHelper(mediaLib);
|
||||||
Assert.assertTrue(helper.isOrder());
|
Assert.assertTrue(helper.itemsAreInOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -66,7 +66,7 @@ public class MultimediaTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void photosView() throws InterruptedException {
|
public void photosView() throws InterruptedException, NoSuchMethodException {
|
||||||
log.logp(INFO, getClass().getName(), "photosView", "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);
|
||||||
@ -91,7 +91,7 @@ public class MultimediaTests {
|
|||||||
|
|
||||||
MediaLibPageHelper helper = new MediaLibPageHelper(mediaLib);
|
MediaLibPageHelper helper = new MediaLibPageHelper(mediaLib);
|
||||||
|
|
||||||
Assert.assertTrue(helper.isOrder());
|
Assert.assertTrue(helper.itemsAreInOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -2,13 +2,9 @@ package PageHelpers;
|
|||||||
|
|
||||||
import Pages.AlbumPage;
|
import Pages.AlbumPage;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import static java.util.logging.Level.INFO;
|
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
|
|
||||||
public class AlbumPageHelper {
|
public class AlbumPageHelper {
|
||||||
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
|
||||||
private AlbumPage page;
|
private AlbumPage page;
|
||||||
public AlbumPageHelper(AlbumPage page){
|
public AlbumPageHelper(AlbumPage page){
|
||||||
this.page = page;
|
this.page = page;
|
||||||
@ -27,42 +23,20 @@ public class AlbumPageHelper {
|
|||||||
return containsPreview;
|
return containsPreview;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSelectedPhoto(int elementNumber) throws InterruptedException {
|
public boolean isSelectedPhoto(int elementNumber) throws NoSuchMethodException {
|
||||||
|
|
||||||
int timeout = 10;
|
Method method = AlbumPageHelper.class.getMethod("clickAndCheckSelectedPhoto", int.class);
|
||||||
boolean isSelected = false;
|
return WaitingForElementToLoadHelper.waitAndCheckSelection(method,this,new Object[]{elementNumber});
|
||||||
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;
|
public void clickPhotoLink(int elementNumber) throws NoSuchMethodException {
|
||||||
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;
|
Method method = AlbumPage.class.getMethod("clickPhotoLink", int.class);
|
||||||
|
WaitingForElementToLoadHelper.waitAndCallMethod(method,page,new Object[]{elementNumber});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public boolean clickAndCheckSelectedPhoto(int elementNumber){
|
||||||
if (breakIt) {
|
page.clickPhotoPopup();
|
||||||
break;
|
return page.isSelectedPhoto(elementNumber);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,16 @@ package PageHelpers;
|
|||||||
import Pages.CalculatorPage;
|
import Pages.CalculatorPage;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import static java.lang.Math.round;
|
import static java.lang.Math.round;
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
|
|
||||||
public class CalculatorPageHelper {
|
public class CalculatorPageHelper {
|
||||||
private static Logger log = Logger.getLogger(CalculatorPageHelper.class.getName());
|
|
||||||
|
|
||||||
private CalculatorPage page;
|
private CalculatorPage page;
|
||||||
public CalculatorPageHelper(CalculatorPage page){
|
Method insertInputMethod = CalculatorPageHelper.class.getMethod("insertInput", new Class[]{WebElement.class, String.class});
|
||||||
|
|
||||||
|
public CalculatorPageHelper(CalculatorPage page) throws NoSuchMethodException {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,42 +40,21 @@ public class CalculatorPageHelper {
|
|||||||
return ((double) round((reInvPrice-startPrice)/startPrice*100 *100))/100 ==changePriceRe;
|
return ((double) round((reInvPrice-startPrice)/startPrice*100 *100))/100 ==changePriceRe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitAndInsertFromDate(String date){
|
public void waitAndInsertFromDate(String date) {
|
||||||
|
WaitingForElementToLoadHelper.waitAndCallMethod(insertInputMethod,this,new Object[]{page.getFromDateInput(),date});
|
||||||
waitForInputsPresent(page.getFromDateInput(),date);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int tryLimit = 10;
|
public void insertInput(WebElement element,String text){
|
||||||
public void waitForInputsPresent(WebElement element,String text){
|
element.clear();
|
||||||
boolean breakIt = true;
|
element.sendKeys(text);
|
||||||
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){
|
public void waitAndInsertToDate(String date){
|
||||||
|
WaitingForElementToLoadHelper.waitAndCallMethod(insertInputMethod,this,new Object[]{page.getToDateInput(),date});
|
||||||
waitForInputsPresent(page.getToDateInput(),date);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitAndInsertAmount(String amount){
|
public void waitAndInsertAmount(String amount){
|
||||||
|
WaitingForElementToLoadHelper.waitAndCallMethod(insertInputMethod,this,new Object[]{page.getAmountInput(),amount});
|
||||||
waitForInputsPresent(page.getAmountInput(),amount);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,14 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class EventsPageHelper {
|
public class EventsPageHelper {
|
||||||
|
|
||||||
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
|
||||||
private EventsPage page;
|
private EventsPage page;
|
||||||
public EventsPageHelper(EventsPage page){
|
public EventsPageHelper(EventsPage page){
|
||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
public boolean isSuitable(int month) throws ParseException {
|
public boolean eventsMatchByMonth(int month) throws ParseException {
|
||||||
|
|
||||||
boolean suitable = true;
|
boolean suitable = true;
|
||||||
DateFormat format = new SimpleDateFormat("d MMMM, hh:mm");
|
DateFormat format = new SimpleDateFormat("d MMMM, hh:mm");
|
||||||
|
@ -2,16 +2,13 @@ package PageHelpers;
|
|||||||
|
|
||||||
import Pages.FeedbackPage;
|
import Pages.FeedbackPage;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class FeedbackPageHelper {
|
public class FeedbackPageHelper {
|
||||||
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
|
||||||
private FeedbackPage page;
|
private FeedbackPage page;
|
||||||
|
String successMessage = "Ваше сообщение отправлено.";
|
||||||
public FeedbackPageHelper(FeedbackPage page){
|
public FeedbackPageHelper(FeedbackPage page){
|
||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
String successMessage = "Ваше сообщение отправлено.";
|
|
||||||
public boolean isReceiveSuccess(){
|
public boolean isReceiveSuccess(){
|
||||||
String output = page.getOutput();
|
String output = page.getOutput();
|
||||||
return output.equals(successMessage);
|
return output.equals(successMessage);
|
||||||
|
@ -17,7 +17,7 @@ public class MediaLibPageHelper {
|
|||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOrder() throws ParseException {
|
public boolean itemsAreInOrder() throws ParseException {
|
||||||
boolean order = true;
|
boolean order = true;
|
||||||
DateFormat format = new SimpleDateFormat("yyyy.M.d H:m");
|
DateFormat format = new SimpleDateFormat("yyyy.M.d H:m");
|
||||||
Date datePrev = format.parse(page.getDateOfItem(0));
|
Date datePrev = format.parse(page.getDateOfItem(0));
|
||||||
@ -34,17 +34,4 @@ public class MediaLibPageHelper {
|
|||||||
|
|
||||||
return order;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,48 +2,22 @@ package PageHelpers;
|
|||||||
|
|
||||||
import Pages.PurchasesPage;
|
import Pages.PurchasesPage;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static java.util.logging.Level.INFO;
|
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
|
|
||||||
public class PurchasePageHelper {
|
public class PurchasePageHelper {
|
||||||
|
|
||||||
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
||||||
private PurchasesPage page;
|
private PurchasesPage page;
|
||||||
|
private int limit = 10;
|
||||||
public PurchasePageHelper(PurchasesPage page){
|
public PurchasePageHelper(PurchasesPage page){
|
||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int tryLimit = 10;
|
public boolean waitAndCheckPageSelection(int pageNumber) throws InterruptedException, NoSuchMethodException {
|
||||||
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) {
|
Method method = PurchasesPage.class.getMethod("isSelectedPage", int.class);
|
||||||
log.logp(WARNING, getClass().getName(), "waitAndCheckPageSelection","Exception in waitAndCheckPageSelection method");
|
return WaitingForElementToLoadHelper.waitAndCheckSelection(method,page,new Object[]{pageNumber});
|
||||||
|
|
||||||
breakIt = false;
|
|
||||||
}
|
|
||||||
if (breakIt) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return turn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package PageHelpers;
|
|||||||
|
|
||||||
import Pages.SearchResultsPage;
|
import Pages.SearchResultsPage;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -10,7 +11,6 @@ import java.util.Date;
|
|||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static java.util.logging.Level.INFO;
|
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
|
|
||||||
public class SearchResultsPageHelper {
|
public class SearchResultsPageHelper {
|
||||||
@ -21,12 +21,12 @@ public class SearchResultsPageHelper {
|
|||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSuitable(String queryString) throws ParseException {
|
public boolean searchResultsMatchQueryAndInOrder(String queryString) throws ParseException, NoSuchMethodException {
|
||||||
|
|
||||||
boolean order = true;
|
boolean order = true;
|
||||||
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
||||||
Date datePrev = new Date();
|
Date datePrev = new Date();
|
||||||
boolean suitable = true;
|
boolean matched = true;
|
||||||
|
|
||||||
for (int i = 0; i < page.getItemsCount(); i++) {
|
for (int i = 0; i < page.getItemsCount(); i++) {
|
||||||
Date dateCur = format.parse(waitAngGetItemsDate(i));
|
Date dateCur = format.parse(waitAngGetItemsDate(i));
|
||||||
@ -37,101 +37,54 @@ public class SearchResultsPageHelper {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!waitAndGetItemsText(i).toLowerCase().contains(queryString)){
|
if(!waitAngGetItemsText(i).toLowerCase().contains(queryString)){
|
||||||
log.logp(WARNING, getClass().getName(), "simpleSearch", "'" + waitAndGetItemsText(i)+"' is not suitable for '"+queryString+"'");
|
log.logp(WARNING, getClass().getName(), "simpleSearch", "'" + waitAngGetItemsText(i)+"' is not suitable for '"+queryString+"'");
|
||||||
suitable = false;
|
matched = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
datePrev= dateCur;
|
datePrev= dateCur;
|
||||||
}
|
}
|
||||||
return order&&suitable;
|
return order&&matched;
|
||||||
|
|
||||||
}
|
}
|
||||||
public boolean isSuitable(String queryString,int year) throws InterruptedException, ParseException {
|
public boolean searchResultsMatchQueryYearAndInOrder(String queryString, int year) throws ParseException, NoSuchMethodException {
|
||||||
boolean order = true;
|
boolean order = searchResultsMatchQueryAndInOrder(queryString);
|
||||||
|
|
||||||
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
DateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
||||||
Calendar calendar = new GregorianCalendar();
|
Calendar calendar = new GregorianCalendar();
|
||||||
Date datePrev = new Date();
|
boolean matched = true;
|
||||||
|
|
||||||
boolean suitable = true;
|
|
||||||
|
|
||||||
for (int i = 0; i < page.getItemsCount(); i++) {
|
for (int i = 0; i < page.getItemsCount(); i++) {
|
||||||
Date dateCur = new Date();
|
Date dateCur = format.parse(waitAngGetItemsDate(i));
|
||||||
|
calendar.setTime(dateCur);
|
||||||
|
|
||||||
int timeout = 10;
|
matched = matchedByYear(calendar,year);
|
||||||
boolean isSuitableElement = false;
|
if(!matched){
|
||||||
for(int k=0;k<timeout;k++){
|
log.logp(WARNING, getClass().getName(), "searchResultsMatchQueryYearAndInOrder",
|
||||||
dateCur = format.parse(waitAngGetItemsDate(i));
|
" '"+calendar.get(Calendar.YEAR)+"' != '"+year+"'");
|
||||||
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;
|
|
||||||
|
return order&&matched;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matchedByYearAndQuery(String itemText, String query, Calendar calendar, int year){
|
private boolean matchedByYear(Calendar calendar,int year){
|
||||||
return itemText.toLowerCase().contains(query)&&calendar.get(Calendar.YEAR)==year;
|
return calendar.get(Calendar.YEAR)==year;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int tryLimit = 10;
|
public String waitAngGetItemsText(int itemNumber) throws NoSuchMethodException {
|
||||||
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;
|
Method method = SearchResultsPage.class.getMethod("getItemsText", int.class);
|
||||||
}
|
return (String)WaitingForElementToLoadHelper.waitAndCallMethod(method,page,new Object[]{itemNumber});
|
||||||
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;
|
public String waitAngGetItemsDate(int itemNumber) throws NoSuchMethodException {
|
||||||
}
|
|
||||||
if (breakIt) {
|
Method method = SearchResultsPage.class.getMethod("getItemsDate", int.class);
|
||||||
break;
|
return (String) WaitingForElementToLoadHelper.waitAndCallMethod(method, page, new Object[]{itemNumber});
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return date;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@ package PageHelpers;
|
|||||||
|
|
||||||
import Pages.SubsidiariesPage;
|
import Pages.SubsidiariesPage;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
|
|
||||||
|
|
||||||
public class SubsidiariesPageHelper {
|
public class SubsidiariesPageHelper {
|
||||||
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
||||||
private SubsidiariesPage page;
|
private SubsidiariesPage page;
|
||||||
@ -13,37 +15,37 @@ public class SubsidiariesPageHelper {
|
|||||||
this.page = page;
|
this.page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOrder() {
|
public boolean isOrder() throws Exception {
|
||||||
|
|
||||||
boolean order = true;
|
boolean order = checkPercents(page, "getPartOfItemPercent100","compareMethodEquals100",page.getItemsPercent100Count())
|
||||||
|
&&checkPercents(page, "getPartOfItemPercentMore50","compareMethodMore50",page.getItemsPercentMore50Count())
|
||||||
|
&&checkPercents(page, "getPartOfItemPercentLess50","compareMethodLess50",page.getItemsPercentLess50Count());
|
||||||
|
|
||||||
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;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -31,7 +31,7 @@ public class PressPage {
|
|||||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
||||||
menuElements.get(journalPageMenuElementNumber).click();
|
menuElements.get(journalPageMenuElementNumber).click();
|
||||||
}
|
}
|
||||||
public void clickMenuElementEventpage(){
|
public void clickMenuElementEventPage(){
|
||||||
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
wait.until(ExpectedConditions.visibilityOfAllElements(menuElements));
|
||||||
menuElements.get(eventPageMenuElementNumber).click();
|
menuElements.get(eventPageMenuElementNumber).click();
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ public class SearchResultsPage {
|
|||||||
|
|
||||||
public int getItemsCount() {
|
public int getItemsCount() {
|
||||||
int size = searchResultsTexts.size();
|
int size = searchResultsTexts.size();
|
||||||
System.out.println(size);
|
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ public class ChromeContext extends Context {
|
|||||||
prefs.put("plugins.always_open_pdf_externally", true);
|
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