mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
guard missing configuration
This commit is contained in:
@@ -18,20 +18,33 @@
|
||||
import { browser, by, element, ElementFinder, protractor } from 'protractor';
|
||||
import { Logger } from './logger';
|
||||
|
||||
const DEFAULT_TIMEOUT = browser.testConfig.timeouts.visible_timeout ? browser.testConfig.timeouts.visible_timeout : 20000;
|
||||
const NOT_VISIBLE_DEFAULT_TIMEOUT = browser.testConfig.timeouts.no_visible_timeout ? browser.testConfig.timeouts.no_visible_timeout : 20000;
|
||||
|
||||
export class BrowserVisibility {
|
||||
|
||||
static async waitUntilElementIsPresent(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT): Promise<any> {
|
||||
static NOT_VISIBLE_DEFAULT_TIMEOUT = BrowserVisibility.getNoVisibleTimeout() ? browser.params.testConfig.timeouts.no_visible_timeout : 20000;
|
||||
static DEFAULT_TIMEOUT = BrowserVisibility.getVisibleTimeout() ? browser.params.testConfig.timeouts.visible_timeout : 20000;
|
||||
|
||||
static getVisibleTimeout() {
|
||||
if (browser && browser.params && browser.params.testConfig && browser.params.testConfig.timeouts) {
|
||||
return browser.params.testConfig.timeouts.visible_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
static getNoVisibleTimeout() {
|
||||
if (browser && browser.params && browser.params.testConfig && browser.params.testConfig.timeouts) {
|
||||
return browser.params.testConfig.timeouts.no_visible_timeout;
|
||||
}
|
||||
}
|
||||
|
||||
static async waitUntilElementIsPresent(elementToCheck: ElementFinder, waitTimeout: number = BrowserVisibility.DEFAULT_TIMEOUT): Promise<any> {
|
||||
Logger.info(`Wait Until Element Is Present ${elementToCheck.locator().toString()} for ${waitTimeout}`);
|
||||
|
||||
return browser.wait(protractor.ExpectedConditions.presenceOf(elementToCheck), waitTimeout, 'Element is not present ' + elementToCheck.locator());
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for element to be visible
|
||||
*/
|
||||
static async waitUntilElementIsVisible(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT, message: string = 'Element is not visible'): Promise<any> {
|
||||
static async waitUntilElementIsVisible(elementToCheck: ElementFinder, waitTimeout: number = BrowserVisibility.DEFAULT_TIMEOUT, message: string = 'Element is not visible'): Promise<any> {
|
||||
Logger.info(`Wait Until Element Is Visible ${elementToCheck.locator().toString()} for ${waitTimeout}`);
|
||||
|
||||
return browser.wait(protractor.ExpectedConditions.visibilityOf(elementToCheck), waitTimeout, message + elementToCheck.locator());
|
||||
@@ -40,7 +53,7 @@ export class BrowserVisibility {
|
||||
/*
|
||||
* Wait for element to be clickable
|
||||
*/
|
||||
static async waitUntilElementIsClickable(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT): Promise<any> {
|
||||
static async waitUntilElementIsClickable(elementToCheck: ElementFinder, waitTimeout: number = BrowserVisibility.DEFAULT_TIMEOUT): Promise<any> {
|
||||
Logger.info(`Wait Until Element Is Clickable ${elementToCheck.locator().toString()} for ${waitTimeout}`);
|
||||
|
||||
return browser.wait(protractor.ExpectedConditions.elementToBeClickable(elementToCheck), waitTimeout, 'Element is not Clickable ' + elementToCheck.locator());
|
||||
@@ -49,7 +62,7 @@ export class BrowserVisibility {
|
||||
/*
|
||||
* Wait for element to not be present on the page
|
||||
*/
|
||||
static async waitUntilElementIsStale(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT): Promise<any> {
|
||||
static async waitUntilElementIsStale(elementToCheck: ElementFinder, waitTimeout: number = BrowserVisibility.DEFAULT_TIMEOUT): Promise<any> {
|
||||
Logger.info(`Wait Until Element Is Stale ${elementToCheck.locator().toString()} for ${waitTimeout}`);
|
||||
|
||||
return browser.wait(protractor.ExpectedConditions.stalenessOf(elementToCheck), waitTimeout, 'Element is not in stale ' + elementToCheck.locator());
|
||||
@@ -58,7 +71,7 @@ export class BrowserVisibility {
|
||||
/*
|
||||
* Wait for element to not be visible
|
||||
*/
|
||||
static async waitUntilElementIsNotVisible(elementToCheck: ElementFinder, waitTimeout: number = NOT_VISIBLE_DEFAULT_TIMEOUT): Promise<any> {
|
||||
static async waitUntilElementIsNotVisible(elementToCheck: ElementFinder, waitTimeout: number = BrowserVisibility.NOT_VISIBLE_DEFAULT_TIMEOUT): Promise<any> {
|
||||
Logger.info(`Wait Until Element Is Not Visible ${elementToCheck.locator().toString()} for ${waitTimeout}`);
|
||||
|
||||
return browser.wait(protractor.ExpectedConditions.invisibilityOf(elementToCheck), waitTimeout, 'Element is Visible and it should not' + elementToCheck.locator());
|
||||
@@ -67,13 +80,13 @@ export class BrowserVisibility {
|
||||
/*
|
||||
* Wait for element to have value
|
||||
*/
|
||||
static async waitUntilElementHasValue(elementToCheck: ElementFinder, elementValue, waitTimeout: number = DEFAULT_TIMEOUT): Promise<any> {
|
||||
static async waitUntilElementHasValue(elementToCheck: ElementFinder, elementValue, waitTimeout: number = BrowserVisibility.DEFAULT_TIMEOUT): Promise<any> {
|
||||
Logger.info(`Wait Until Element has value ${elementToCheck.locator().toString()} for ${waitTimeout}`);
|
||||
|
||||
return browser.wait(protractor.ExpectedConditions.textToBePresentInElementValue(elementToCheck, elementValue), waitTimeout, 'Element doesn\'t have a value ' + elementToCheck.locator());
|
||||
}
|
||||
|
||||
static async waitUntilElementIsNotPresent(elementToCheck: ElementFinder, waitTimeout: number = NOT_VISIBLE_DEFAULT_TIMEOUT): Promise<any> {
|
||||
static async waitUntilElementIsNotPresent(elementToCheck: ElementFinder, waitTimeout: number = BrowserVisibility.NOT_VISIBLE_DEFAULT_TIMEOUT): Promise<any> {
|
||||
Logger.info(`Wait Until Element is not present ${elementToCheck.locator().toString()} for ${waitTimeout}`);
|
||||
|
||||
return browser.wait(protractor.ExpectedConditions.stalenessOf(elementToCheck), waitTimeout, 'Element is present ' + elementToCheck.locator());
|
||||
|
Reference in New Issue
Block a user