From 9a56201da7bf773fd0a9c881bc8b6ca6c4bf5392 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 Sep 2024 14:33:55 +0200 Subject: [PATCH 1/3] Add `wait-for-text-false` command --- src/commands.js | 1 + src/commands/all.js | 1 + src/commands/wait.js | 25 +++++++++++++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/commands.js b/src/commands.js index 0a6bd5af2..82eb9ecae 100644 --- a/src/commands.js +++ b/src/commands.js @@ -112,6 +112,7 @@ const ORDERS = { 'wait-for-property': commands.parseWaitForProperty, 'wait-for-property-false': commands.parseWaitForPropertyFalse, 'wait-for-size': commands.parseWaitForSize, + 'wait-for-size-false': commands.parseWaitForSizeFalse, 'wait-for-text': commands.parseWaitForText, 'wait-for-text-false': commands.parseWaitForTextFalse, 'wait-for-window-property': commands.parseWaitForWindowProperty, diff --git a/src/commands/all.js b/src/commands/all.js index ed1cb39b3..72f1a97a1 100644 --- a/src/commands/all.js +++ b/src/commands/all.js @@ -120,6 +120,7 @@ module.exports = { 'parseWaitForProperty': wait.parseWaitForProperty, 'parseWaitForPropertyFalse': wait.parseWaitForPropertyFalse, 'parseWaitForSize': wait.parseWaitForSize, + 'parseWaitForSizeFalse': wait.parseWaitForSizeFalse, 'parseWaitForText': wait.parseWaitForText, 'parseWaitForTextFalse': wait.parseWaitForTextFalse, 'parseWaitForWindowProperty': wait.parseWaitForWindowProperty, diff --git a/src/commands/wait.js b/src/commands/wait.js index 8619ff88d..2724f1f70 100644 --- a/src/commands/wait.js +++ b/src/commands/wait.js @@ -1213,11 +1213,24 @@ ${indentString(incr, 1)} 'checkResult': true, }; } + // Possible inputs: // // * ("CSS selector", JSON dict) // * ("XPath", JSON dict) function parseWaitForSize(parser) { + return parseWaitForSizeInner(parser, false); +} + +// Possible inputs: +// +// * ("CSS selector", JSON dict) +// * ("XPath", JSON dict) +function parseWaitForSizeFalse(parser) { + return parseWaitForSizeInner(parser, true); +} + +function parseWaitForSizeInner(parser, waitFalse) { const identifiers = ['ALL']; const ret = validator(parser, { kind: 'tuple', @@ -1278,17 +1291,24 @@ function parseWaitForSize(parser) { const whole = commonSizeCheckCode( selector, enabledChecks.has('ALL'), false, json, varName, errorsVarName); + let comp = '==='; + let errorMessage = '"The following checks still fail: [" + err + "]"'; + if (waitFalse) { + comp = '!=='; + errorMessage = '"All checks still pass"'; + } + const [init, looper] = waitForElement(selector, varName, {checkAll: enabledChecks.has('ALL')}); const incr = incrWait(`\ const err = ${errorsVarName}.join(", "); -throw new Error("The following checks still fail: [" + err + "]");`); +throw new Error(${errorMessage});`); const instructions = `\ ${init} while (true) { ${indentString(looper, 1)} ${indentString(whole, 1)} - if (errors.length === 0) { + if (errors.length ${comp} 0) { break; } @@ -1325,4 +1345,5 @@ module.exports = { 'parseWaitForWindowProperty': parseWaitForWindowProperty, 'parseWaitForWindowPropertyFalse': parseWaitForWindowPropertyFalse, 'parseWaitForSize': parseWaitForSize, + 'parseWaitForSizeFalse': parseWaitForSizeFalse, }; From d033f45cb147c2243f902a674f3891e60370c2ca Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 Sep 2024 14:35:27 +0200 Subject: [PATCH 2/3] Add tests for `wait-for-text-false` command --- .../parseWaitForSizeFalse/basic-1.toml | 51 ++++++++++++++++ .../parseWaitForSizeFalse/basic-2.toml | 53 ++++++++++++++++ .../parseWaitForSizeFalse/basic-3.toml | 57 ++++++++++++++++++ .../parseWaitForSizeFalse/basic-4.toml | 53 ++++++++++++++++ .../parseWaitForSizeFalse/basic-5.toml | 57 ++++++++++++++++++ .../parseWaitForSizeFalse/err-1.toml | 1 + .../parseWaitForSizeFalse/err-10.toml | 1 + .../parseWaitForSizeFalse/err-2.toml | 1 + .../parseWaitForSizeFalse/err-3.toml | 1 + .../parseWaitForSizeFalse/err-4.toml | 1 + .../parseWaitForSizeFalse/err-5.toml | 1 + .../parseWaitForSizeFalse/err-6.toml | 1 + .../parseWaitForSizeFalse/err-7.toml | 1 + .../parseWaitForSizeFalse/err-8.toml | 1 + .../parseWaitForSizeFalse/err-9.toml | 1 + .../parseWaitForSizeFalse/multiline-1.toml | 1 + .../parseWaitForSizeFalse/multiline-2.toml | 60 +++++++++++++++++++ .../parseWaitForSizeFalse/pseudo-1.toml | 60 +++++++++++++++++++ .../parseWaitForSizeFalse/pseudo-2.toml | 60 +++++++++++++++++++ .../parseWaitForSizeFalse/pseudo-3.toml | 53 ++++++++++++++++ .../parseWaitForSizeFalse/pseudo-4.toml | 57 ++++++++++++++++++ .../parseWaitForSizeFalse/pseudo-5.toml | 53 ++++++++++++++++ .../parseWaitForSizeFalse/pseudo-6.toml | 57 ++++++++++++++++++ .../parseWaitForSizeFalse/pseudo-7.toml | 57 ++++++++++++++++++ .../parseWaitForSizeFalse/xpath-1.toml | 51 ++++++++++++++++ .../parseWaitForSizeFalse/xpath-2.toml | 53 ++++++++++++++++ .../parseWaitForSizeFalse/xpath-3.toml | 57 ++++++++++++++++++ .../parseWaitForSizeFalse/xpath-4.toml | 56 +++++++++++++++++ .../parseWaitForSizeFalse/xpath-5.toml | 60 +++++++++++++++++++ tests/ui/wait-for-size-false.goml | 16 +++++ tests/ui/wait-for-size-false.output | 7 +++ tests/ui/wait-for-size.goml | 2 + tests/ui/wait-for-size.output | 1 + tools/api.js | 5 ++ 34 files changed, 1047 insertions(+) create mode 100644 tests/api-output/parseWaitForSizeFalse/basic-1.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/basic-2.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/basic-3.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/basic-4.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/basic-5.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/err-1.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/err-10.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/err-2.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/err-3.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/err-4.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/err-5.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/err-6.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/err-7.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/err-8.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/err-9.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/multiline-1.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/multiline-2.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/pseudo-1.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/pseudo-2.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/pseudo-3.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/pseudo-4.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/pseudo-5.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/pseudo-6.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/pseudo-7.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/xpath-1.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/xpath-2.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/xpath-3.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/xpath-4.toml create mode 100644 tests/api-output/parseWaitForSizeFalse/xpath-5.toml create mode 100644 tests/ui/wait-for-size-false.goml create mode 100644 tests/ui/wait-for-size-false.output diff --git a/tests/api-output/parseWaitForSizeFalse/basic-1.toml b/tests/api-output/parseWaitForSizeFalse/basic-1.toml new file mode 100644 index 000000000..01090ec47 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/basic-1.toml @@ -0,0 +1,51 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a\"); + if (assertSize.length !== 0) { + assertSize = assertSize[0]; + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + + return innerErrors; + }); + } + const errors = []; + errors.push(...await checkElemSize(assertSize)); + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/basic-2.toml b/tests/api-output/parseWaitForSizeFalse/basic-2.toml new file mode 100644 index 000000000..516d2bdc9 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/basic-2.toml @@ -0,0 +1,53 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a\"); + if (assertSize.length !== 0) { + assertSize = assertSize[0]; + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (width !== 1) { + innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + errors.push(...await checkElemSize(assertSize)); + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/basic-3.toml b/tests/api-output/parseWaitForSizeFalse/basic-3.toml new file mode 100644 index 000000000..555336a41 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/basic-3.toml @@ -0,0 +1,57 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a\"); + if (assertSize.length !== 0) { + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (width !== 1) { + innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + for (const elem of assertSize) { + errors.push(...await checkElemSize(elem)); + if (errors.length !== 0) { + break; + } + } + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/basic-4.toml b/tests/api-output/parseWaitForSizeFalse/basic-4.toml new file mode 100644 index 000000000..c98655d12 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/basic-4.toml @@ -0,0 +1,53 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a\"); + if (assertSize.length !== 0) { + assertSize = assertSize[0]; + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (height !== 1) { + innerErrors.push(\"expected a height of `1`, found `\" + height + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + errors.push(...await checkElemSize(assertSize)); + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/basic-5.toml b/tests/api-output/parseWaitForSizeFalse/basic-5.toml new file mode 100644 index 000000000..15334cf12 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/basic-5.toml @@ -0,0 +1,57 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a\"); + if (assertSize.length !== 0) { + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (height !== 1) { + innerErrors.push(\"expected a height of `1`, found `\" + height + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + for (const elem of assertSize) { + errors.push(...await checkElemSize(elem)); + if (errors.length !== 0) { + break; + } + } + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/err-1.toml b/tests/api-output/parseWaitForSizeFalse/err-1.toml new file mode 100644 index 000000000..85a179c48 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/err-1.toml @@ -0,0 +1 @@ +error = """expected a JSON dict, found `\"b\"` (a string) (second element of the tuple)""" diff --git a/tests/api-output/parseWaitForSizeFalse/err-10.toml b/tests/api-output/parseWaitForSizeFalse/err-10.toml new file mode 100644 index 000000000..259042b0f --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/err-10.toml @@ -0,0 +1 @@ +error = """unexpected key `\"z\"`, allowed keys are: [`height`, `width`] (second element of the tuple)""" diff --git a/tests/api-output/parseWaitForSizeFalse/err-2.toml b/tests/api-output/parseWaitForSizeFalse/err-2.toml new file mode 100644 index 000000000..85a179c48 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/err-2.toml @@ -0,0 +1 @@ +error = """expected a JSON dict, found `\"b\"` (a string) (second element of the tuple)""" diff --git a/tests/api-output/parseWaitForSizeFalse/err-3.toml b/tests/api-output/parseWaitForSizeFalse/err-3.toml new file mode 100644 index 000000000..2836aef7f --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/err-3.toml @@ -0,0 +1 @@ +error = """expected `,` or `)` after `\"b\"`, found `\"c\"`""" diff --git a/tests/api-output/parseWaitForSizeFalse/err-4.toml b/tests/api-output/parseWaitForSizeFalse/err-4.toml new file mode 100644 index 000000000..2836aef7f --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/err-4.toml @@ -0,0 +1 @@ +error = """expected `,` or `)` after `\"b\"`, found `\"c\"`""" diff --git a/tests/api-output/parseWaitForSizeFalse/err-5.toml b/tests/api-output/parseWaitForSizeFalse/err-5.toml new file mode 100644 index 000000000..85a179c48 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/err-5.toml @@ -0,0 +1 @@ +error = """expected a JSON dict, found `\"b\"` (a string) (second element of the tuple)""" diff --git a/tests/api-output/parseWaitForSizeFalse/err-6.toml b/tests/api-output/parseWaitForSizeFalse/err-6.toml new file mode 100644 index 000000000..af8a2fc6d --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/err-6.toml @@ -0,0 +1 @@ +error = """unexpected ident `all` (third element of the tuple). Allowed idents are: [`ALL`]""" diff --git a/tests/api-output/parseWaitForSizeFalse/err-7.toml b/tests/api-output/parseWaitForSizeFalse/err-7.toml new file mode 100644 index 000000000..9e9d8ce51 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/err-7.toml @@ -0,0 +1 @@ +error = """unexpected ident `ALLO` (third element of the tuple). Allowed idents are: [`ALL`]""" diff --git a/tests/api-output/parseWaitForSizeFalse/err-8.toml b/tests/api-output/parseWaitForSizeFalse/err-8.toml new file mode 100644 index 000000000..a36cb8a53 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/err-8.toml @@ -0,0 +1 @@ +error = """unexpected key `\"b\"`, allowed keys are: [`height`, `width`] (second element of the tuple)""" diff --git a/tests/api-output/parseWaitForSizeFalse/err-9.toml b/tests/api-output/parseWaitForSizeFalse/err-9.toml new file mode 100644 index 000000000..95ee96e7f --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/err-9.toml @@ -0,0 +1 @@ +error = """type \"string\" (`\"\"`) is not allowed as value in this JSON dict, allowed types are: [`number`] (second element of the tuple)""" diff --git a/tests/api-output/parseWaitForSizeFalse/multiline-1.toml b/tests/api-output/parseWaitForSizeFalse/multiline-1.toml new file mode 100644 index 000000000..c9c20e92d --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/multiline-1.toml @@ -0,0 +1 @@ +error = """`width` key is duplicated in JSON dict (second element of the tuple)""" diff --git a/tests/api-output/parseWaitForSizeFalse/multiline-2.toml b/tests/api-output/parseWaitForSizeFalse/multiline-2.toml new file mode 100644 index 000000000..10ef905b5 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/multiline-2.toml @@ -0,0 +1,60 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"::-p-xpath(//a)\"); + if (assertSize.length !== 0) { + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The XPath \\\"//a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (width !== 1) { + innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\"); + } + if (height !== 2) { + innerErrors.push(\"expected a height of `2`, found `\" + height + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + for (const elem of assertSize) { + errors.push(...await checkElemSize(elem)); + if (errors.length !== 0) { + break; + } + } + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/pseudo-1.toml b/tests/api-output/parseWaitForSizeFalse/pseudo-1.toml new file mode 100644 index 000000000..539f9b049 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/pseudo-1.toml @@ -0,0 +1,60 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a\"); + if (assertSize.length !== 0) { + assertSize = assertSize[0]; + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const style = getComputedStyle(e, \"::after\"); + let height = parseFloat(style[\"height\"]); + let width = parseFloat(style[\"width\"]); + if (style[\"box-sizing\"] !== \"border-box\") { + height += parseFloat(style[\"padding-top\"]) + parseFloat(style[\"padding-bottom\"]); + height += parseFloat(style[\"border-top-width\"]) + parseFloat(style[\"border-bottom-width\"]); + width += parseFloat(style[\"padding-left\"]) + parseFloat(style[\"padding-right\"]); + width += parseFloat(style[\"border-left-width\"]) + parseFloat(style[\"border-right-width\"]); + } + if (width !== 1) { + innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + errors.push(...await checkElemSize(assertSize)); + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/pseudo-2.toml b/tests/api-output/parseWaitForSizeFalse/pseudo-2.toml new file mode 100644 index 000000000..9828eb546 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/pseudo-2.toml @@ -0,0 +1,60 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a\"); + if (assertSize.length !== 0) { + assertSize = assertSize[0]; + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const style = getComputedStyle(e, \"::after\"); + let height = parseFloat(style[\"height\"]); + let width = parseFloat(style[\"width\"]); + if (style[\"box-sizing\"] !== \"border-box\") { + height += parseFloat(style[\"padding-top\"]) + parseFloat(style[\"padding-bottom\"]); + height += parseFloat(style[\"border-top-width\"]) + parseFloat(style[\"border-bottom-width\"]); + width += parseFloat(style[\"padding-left\"]) + parseFloat(style[\"padding-right\"]); + width += parseFloat(style[\"border-left-width\"]) + parseFloat(style[\"border-right-width\"]); + } + if (height !== 1) { + innerErrors.push(\"expected a height of `1`, found `\" + height + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + errors.push(...await checkElemSize(assertSize)); + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/pseudo-3.toml b/tests/api-output/parseWaitForSizeFalse/pseudo-3.toml new file mode 100644 index 000000000..34fce1a0c --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/pseudo-3.toml @@ -0,0 +1,53 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a:focus\"); + if (assertSize.length !== 0) { + assertSize = assertSize[0]; + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a:focus\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (width !== 1) { + innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + errors.push(...await checkElemSize(assertSize)); + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/pseudo-4.toml b/tests/api-output/parseWaitForSizeFalse/pseudo-4.toml new file mode 100644 index 000000000..353d1ede1 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/pseudo-4.toml @@ -0,0 +1,57 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a:focus\"); + if (assertSize.length !== 0) { + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a:focus\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (height !== 1) { + innerErrors.push(\"expected a height of `1`, found `\" + height + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + for (const elem of assertSize) { + errors.push(...await checkElemSize(elem)); + if (errors.length !== 0) { + break; + } + } + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/pseudo-5.toml b/tests/api-output/parseWaitForSizeFalse/pseudo-5.toml new file mode 100644 index 000000000..fcee231a1 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/pseudo-5.toml @@ -0,0 +1,53 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a ::after\"); + if (assertSize.length !== 0) { + assertSize = assertSize[0]; + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a ::after\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (width !== 1) { + innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + errors.push(...await checkElemSize(assertSize)); + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/pseudo-6.toml b/tests/api-output/parseWaitForSizeFalse/pseudo-6.toml new file mode 100644 index 000000000..edf9c1fd6 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/pseudo-6.toml @@ -0,0 +1,57 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a ::after\"); + if (assertSize.length !== 0) { + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a ::after\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (height !== 1) { + innerErrors.push(\"expected a height of `1`, found `\" + height + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + for (const elem of assertSize) { + errors.push(...await checkElemSize(elem)); + if (errors.length !== 0) { + break; + } + } + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/pseudo-7.toml b/tests/api-output/parseWaitForSizeFalse/pseudo-7.toml new file mode 100644 index 000000000..c1b9c9459 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/pseudo-7.toml @@ -0,0 +1,57 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"a ::after\"); + if (assertSize.length !== 0) { + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The CSS selector \\\"a ::after\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (width !== 1.14) { + innerErrors.push(\"expected a width of `1.14`, found `\" + width + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + for (const elem of assertSize) { + errors.push(...await checkElemSize(elem)); + if (errors.length !== 0) { + break; + } + } + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/xpath-1.toml b/tests/api-output/parseWaitForSizeFalse/xpath-1.toml new file mode 100644 index 000000000..99bc004fa --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/xpath-1.toml @@ -0,0 +1,51 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"::-p-xpath(//a)\"); + if (assertSize.length !== 0) { + assertSize = assertSize[0]; + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The XPath \\\"//a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + + return innerErrors; + }); + } + const errors = []; + errors.push(...await checkElemSize(assertSize)); + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/xpath-2.toml b/tests/api-output/parseWaitForSizeFalse/xpath-2.toml new file mode 100644 index 000000000..d3a351005 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/xpath-2.toml @@ -0,0 +1,53 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"::-p-xpath(//a)\"); + if (assertSize.length !== 0) { + assertSize = assertSize[0]; + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The XPath \\\"//a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (width !== 1) { + innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + errors.push(...await checkElemSize(assertSize)); + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/xpath-3.toml b/tests/api-output/parseWaitForSizeFalse/xpath-3.toml new file mode 100644 index 000000000..1025de1ec --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/xpath-3.toml @@ -0,0 +1,57 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"::-p-xpath(//a)\"); + if (assertSize.length !== 0) { + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The XPath \\\"//a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (width !== 1) { + innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + for (const elem of assertSize) { + errors.push(...await checkElemSize(elem)); + if (errors.length !== 0) { + break; + } + } + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/xpath-4.toml b/tests/api-output/parseWaitForSizeFalse/xpath-4.toml new file mode 100644 index 000000000..772ccae6b --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/xpath-4.toml @@ -0,0 +1,56 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"::-p-xpath(//a)\"); + if (assertSize.length !== 0) { + assertSize = assertSize[0]; + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The XPath \\\"//a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (width !== 1) { + innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\"); + } + if (height !== 2) { + innerErrors.push(\"expected a height of `2`, found `\" + height + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + errors.push(...await checkElemSize(assertSize)); + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/api-output/parseWaitForSizeFalse/xpath-5.toml b/tests/api-output/parseWaitForSizeFalse/xpath-5.toml new file mode 100644 index 000000000..10ef905b5 --- /dev/null +++ b/tests/api-output/parseWaitForSizeFalse/xpath-5.toml @@ -0,0 +1,60 @@ +instructions = [ + """const timeLimit = page.getDefaultTimeout(); +const timeAdd = 50; +let allTime = 0; +let assertSize = null; +while (true) { + while (true) { + assertSize = await page.$$(\"::-p-xpath(//a)\"); + if (assertSize.length !== 0) { + break; + } + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + throw new Error(\"The XPath \\\"//a\\\" was not found\"); + } + } + async function checkElemSize(elem) { + return await elem.evaluate(e => { + const innerErrors = []; + const height = e.offsetHeight; + const width = e.offsetWidth; + if (width !== 1) { + innerErrors.push(\"expected a width of `1`, found `\" + width + \"`\"); + } + if (height !== 2) { + innerErrors.push(\"expected a height of `2`, found `\" + height + \"`\"); + } + return innerErrors; + }); + } + const errors = []; + for (const elem of assertSize) { + errors.push(...await checkElemSize(elem)); + if (errors.length !== 0) { + break; + } + } + if (errors.length !== 0) { + break; + } + + await new Promise(r => setTimeout(r, timeAdd)); + if (timeLimit === 0) { + continue; + } + allTime += timeAdd; + if (allTime >= timeLimit) { + const err = errors.join(\", \"); + throw new Error(\"All checks still pass\"); + } +}""", +] +wait = false +warnings = [ +] +checkResult = true diff --git a/tests/ui/wait-for-size-false.goml b/tests/ui/wait-for-size-false.goml new file mode 100644 index 000000000..2d218745c --- /dev/null +++ b/tests/ui/wait-for-size-false.goml @@ -0,0 +1,16 @@ +// This test ensures that the `wait-for-size-false` command is behaving like expected. +screenshot-comparison: false +go-to: "file://" + |CURRENT_DIR| + "/" + |DOC_PATH| + "/elements.html" +set-timeout: 400 +// Shouldn't wait here since it's already not the case. +wait-for-size-false: ("#js-change-size", {"width": 31, "height": 21}) +click: "#js-change-size" +// Should wait for 250ms here. +wait-for-size-false: ("#js-change-size", {"width": 30}) +click: "#js-change-size" +// Should wait for 250ms here. +wait-for-size-false: ("#js-change-size", {"height": 20}, ALL) +// This next one should fail. +wait-for-size-false: ("#js-change-size", {"height": 27, "width": 34}) +// And it should not stop the script. +assert-size: ("#js-change-size", {"height": 26, "width": 33}) diff --git a/tests/ui/wait-for-size-false.output b/tests/ui/wait-for-size-false.output new file mode 100644 index 000000000..56aec69a1 --- /dev/null +++ b/tests/ui/wait-for-size-false.output @@ -0,0 +1,7 @@ +=> Starting doc-ui tests... + +wait-for-size-false... FAILED +[ERROR] `tests/ui/wait-for-size-false.goml` line 16: The following errors happened: [expected a height of `26`, found `23`]: for command `assert-size: ("#js-change-size", {"height": 26, "width": 33})` + + +<= doc-ui tests done: 0 succeeded, 1 failed \ No newline at end of file diff --git a/tests/ui/wait-for-size.goml b/tests/ui/wait-for-size.goml index 4ee702916..07c6b6e00 100644 --- a/tests/ui/wait-for-size.goml +++ b/tests/ui/wait-for-size.goml @@ -12,3 +12,5 @@ click: "#js-change-size" wait-for-size: ("#js-change-size", {"height": 26}, ALL) // This next one should fail. wait-for-size: ("#js-change-size", {"height": 26, "width": 33}) +// And it should not stop the script. +assert-size: ("#js-change-size", {"height": 26, "width": 33}) diff --git a/tests/ui/wait-for-size.output b/tests/ui/wait-for-size.output index 50b3d662f..1f8cffa9d 100644 --- a/tests/ui/wait-for-size.output +++ b/tests/ui/wait-for-size.output @@ -2,6 +2,7 @@ wait-for-size... FAILED [ERROR] `tests/ui/wait-for-size.goml` line 14: Error: The following checks still fail: [expected a width of `33`, found `36`]: for command `wait-for-size: ("#js-change-size", {"height": 26, "width": 33})` +[ERROR] `tests/ui/wait-for-size.goml` line 16: The following errors happened: [expected a width of `33`, found `36`]: for command `assert-size: ("#js-change-size", {"height": 26, "width": 33})` <= doc-ui tests done: 0 succeeded, 1 failed \ No newline at end of file diff --git a/tools/api.js b/tools/api.js index 59c0b2d64..af31f8763 100644 --- a/tools/api.js +++ b/tools/api.js @@ -2923,6 +2923,11 @@ const TO_CHECK = [ 'func': checkAssertSize, 'toCall': (x, e, name, o) => wrapper(parserFuncs.parseWaitForSize, x, e, name, o), }, + { + 'name': 'wait-for-size-false', + 'func': checkAssertSize, + 'toCall': (x, e, name, o) => wrapper(parserFuncs.parseWaitForSizeFalse, x, e, name, o), + }, { 'name': 'wait-for-text', 'func': checkWaitForText, From d1737c00aa3f87648118775dc887f849b5b0dd5c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 27 Sep 2024 14:35:47 +0200 Subject: [PATCH 3/3] Add documentation for `wait-for-text-false` command --- goml-script.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/goml-script.md b/goml-script.md index 6d60a97fc..19f76c58f 100644 --- a/goml-script.md +++ b/goml-script.md @@ -243,6 +243,7 @@ Here's the command list: * [`wait-for-text`](#wait-for-text) * [`wait-for-text-false`](#wait-for-text-false) * [`wait-for-size`](#wait-for-size) + * [`wait-for-size-false`](#wait-for-size-false) * [`wait-for-window-property`](#wait-for-window-property) * [`wait-for-window-property-false`](#wait-for-window-property-false) * [`write`](#write) @@ -2253,7 +2254,7 @@ If you want to wait for all properties to have the expected values, take a look #### wait-for-size -**wait-for-size** command wait for the given element(s) that either the "width" or the "height" (or both) have the expected value. Examples: +**wait-for-size** command waits for the given element(s) that either the "width" or the "height" (or both) have the expected value. Examples: ``` wait-for-size: ("button", {"width": 200, "height": 20}) @@ -2269,7 +2270,28 @@ wait-for-size: ("button", {"width": 200, "height": 20}, ALL) wait-for-size: ("//button", {"width": 200, "height": 20}, ALL) ``` -To be more exact, this command compares the "offsetWidth" and "offsetHeight", which include the content +To be more exact, this command compares the "offsetWidth" and "offsetHeight", which includes the content +size, the padding and the border. + +#### wait-for-size-false + +**wait-for-size-false** command waits for any of the given element(s) that either the "width" or the "height" (or both) not have the expected value. Examples: + +``` +wait-for-size-false: ("button", {"width": 200, "height": 20}) +// Same with XPath +wait-for-size-false: ("//button", {"width": 200, "height": 20}) +``` + +If you want to check that any of the elements matching the given selector do not have the expected value(s), use `ALL`: + +``` +wait-for-size-false: ("button", {"width": 200, "height": 20}, ALL) +// Same with XPath +wait-for-size-false: ("//button", {"width": 200, "height": 20}, ALL) +``` + +To be more exact, this command compares the "offsetWidth" and "offsetHeight", which includes the content size, the padding and the border. #### wait-for-text