Skip to content

Commit fbd1d14

Browse files
Add wait-for-size-false command
1 parent 8a8b36e commit fbd1d14

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/commands.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ const ORDERS = {
112112
'wait-for-property': commands.parseWaitForProperty,
113113
'wait-for-property-false': commands.parseWaitForPropertyFalse,
114114
'wait-for-size': commands.parseWaitForSize,
115+
'wait-for-size-false': commands.parseWaitForSizeFalse,
115116
'wait-for-text': commands.parseWaitForText,
116117
'wait-for-text-false': commands.parseWaitForTextFalse,
117118
'wait-for-window-property': commands.parseWaitForWindowProperty,

src/commands/all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ module.exports = {
120120
'parseWaitForProperty': wait.parseWaitForProperty,
121121
'parseWaitForPropertyFalse': wait.parseWaitForPropertyFalse,
122122
'parseWaitForSize': wait.parseWaitForSize,
123+
'parseWaitForSizeFalse': wait.parseWaitForSizeFalse,
123124
'parseWaitForText': wait.parseWaitForText,
124125
'parseWaitForTextFalse': wait.parseWaitForTextFalse,
125126
'parseWaitForWindowProperty': wait.parseWaitForWindowProperty,

src/commands/wait.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,11 +1213,24 @@ ${indentString(incr, 1)}
12131213
'checkResult': true,
12141214
};
12151215
}
1216+
12161217
// Possible inputs:
12171218
//
12181219
// * ("CSS selector", JSON dict)
12191220
// * ("XPath", JSON dict)
12201221
function parseWaitForSize(parser) {
1222+
return parseWaitForSizeInner(parser, false);
1223+
}
1224+
1225+
// Possible inputs:
1226+
//
1227+
// * ("CSS selector", JSON dict)
1228+
// * ("XPath", JSON dict)
1229+
function parseWaitForSizeFalse(parser) {
1230+
return parseWaitForSizeInner(parser, true);
1231+
}
1232+
1233+
function parseWaitForSizeInner(parser, waitFalse) {
12211234
const identifiers = ['ALL'];
12221235
const ret = validator(parser, {
12231236
kind: 'tuple',
@@ -1278,17 +1291,24 @@ function parseWaitForSize(parser) {
12781291
const whole = commonSizeCheckCode(
12791292
selector, enabledChecks.has('ALL'), false, json, varName, errorsVarName);
12801293

1294+
let comp = '===';
1295+
let errorMessage = '"The following checks still fail: [" + err + "]"';
1296+
if (waitFalse) {
1297+
comp = '!==';
1298+
errorMessage = '"All checks still pass"';
1299+
}
1300+
12811301
const [init, looper] = waitForElement(selector, varName, {checkAll: enabledChecks.has('ALL')});
12821302
const incr = incrWait(`\
12831303
const err = ${errorsVarName}.join(", ");
1284-
throw new Error("The following checks still fail: [" + err + "]");`);
1304+
throw new Error(${errorMessage});`);
12851305

12861306
const instructions = `\
12871307
${init}
12881308
while (true) {
12891309
${indentString(looper, 1)}
12901310
${indentString(whole, 1)}
1291-
if (errors.length === 0) {
1311+
if (errors.length ${comp} 0) {
12921312
break;
12931313
}
12941314
@@ -1325,4 +1345,5 @@ module.exports = {
13251345
'parseWaitForWindowProperty': parseWaitForWindowProperty,
13261346
'parseWaitForWindowPropertyFalse': parseWaitForWindowPropertyFalse,
13271347
'parseWaitForSize': parseWaitForSize,
1348+
'parseWaitForSizeFalse': parseWaitForSizeFalse,
13281349
};

0 commit comments

Comments
 (0)