Skip to content

Commit f2960d9

Browse files
committed
[Helpers] Added test cases for I.waitForDetached and changed error messages so they are they same across all helpers
1 parent 13e1ffa commit f2960d9

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Opposite to `seeElement`. Checks that element is not visible
1+
Opposite to `seeElement`. Checks that element is not visible (or in DOM)
22

33
@param locator located by CSS|XPath|Strict locator

lib/helper/Nightmare.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ class Nightmare extends Helper {
907907

908908
return this.browser.wait((by, locator) => window.codeceptjs.findElement(by, locator) === null, locator.type, locator.value).catch((err) => {
909909
if (err.message && err.message.indexOf('.wait() timed out after') > -1) {
910-
throw new Error(`element (${JSON.stringify(locator)}) still present on page after ${sec} sec`);
910+
throw new Error(`element (${JSON.stringify(locator)}) still on page after ${sec} sec`);
911911
} else throw err;
912912
});
913913
}

lib/helper/Protractor.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,11 @@ class Protractor extends Helper {
919919
async waitForDetached(locator, sec = null) {
920920
const aSec = sec || this.options.waitForTimeout;
921921
const el = global.element(guessLocator(locator) || global.by.css(locator));
922-
return this.browser.wait(EC.not(EC.presenceOf(el)), aSec * 1000);
922+
return this.browser.wait(EC.not(EC.presenceOf(el)), aSec * 1000).catch((err) => {
923+
if (err.message && err.message.indexOf('Wait timed out after') > -1) {
924+
throw new Error(`element (${JSON.stringify(locator)}) still on page after ${sec} sec`);
925+
} else throw err;
926+
});
923927
}
924928

925929
/**
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<html>
2+
<head>
3+
<style>
4+
.invisible_button { display: none; }
5+
</style>
6+
</head>
7+
8+
<body>
9+
10+
<div id="step_1">Step One Button</div>
11+
<div id="step_2">Step Two Button</div>
12+
<script>
13+
setTimeout(function () {
14+
document.getElementById('step_1').style.display = 'none'; // Hide button
15+
var step2 = document.getElementById('step_2'); // Remove button
16+
step2.parentElement.removeChild(step2);
17+
}, 1000);
18+
19+
</script>
20+
21+
</body>
22+
</html>

0 commit comments

Comments
 (0)