save screenshot files only if they are present

This commit is contained in:
Eugenio Romano
2018-07-09 11:21:57 +01:00
parent fabcefeba6
commit f0ee0bda2f
2 changed files with 47 additions and 22 deletions

View File

@@ -335,13 +335,37 @@ exports.waitUntilUrlIsShowed = function (urlToWait, timeout) {
exports.waitUntilElementIsVisible = function (elementToCheck, timeout) {
var waitTimeout = timeout || DEFAULT_TIMEOUT;
return browser.wait(until.visibilityOf(elementToCheck), waitTimeout, 'Element is not visible ' + elementToCheck.locator());
this.waitUntilElementIsPresent(elementToCheck, timeout);
var isDisplayed = false;
return browser.wait(() => {
elementToCheck.isDisplayed().then(
() => {
isDisplayed = true;
},
(err) => {
isDisplayed = false;
}
);
return isDisplayed;
}, waitTimeout, 'Element is not visible ' + elementToCheck.locator());
};
exports.waitUntilElementIsPresent = function (elementToCheck, timeout) {
var waitTimeout = timeout || DEFAULT_TIMEOUT;
return browser.wait(until.presenceOf(elementToCheck), waitTimeout, 'Element is not present ' + elementToCheck.locator());
var isPresent = false;
return browser.wait(() => {
elementToCheck.isPresent().then(
() => {
isPresent = true;
},
(err) => {
isPresent = false;
}
);
return isPresent;
}, waitTimeout, 'Element is not present ' + elementToCheck.locator());
};
/**