-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #619 from GuillaumeGomez/wait-for-property-false
Add `wait-for-property-false` command'
- Loading branch information
Showing
29 changed files
with
1,195 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
instructions = [ | ||
"""async function checkPropForElem(elem) { | ||
return await elem.evaluate(e => { | ||
function checkObjectPaths(object, path, callback, notFoundCallback) { | ||
const found = []; | ||
for (const subPath of path) { | ||
found.push(subPath); | ||
if (object === undefined || object === null) { | ||
notFoundCallback(found); | ||
return; | ||
} | ||
object = object[subPath]; | ||
} | ||
callback(object); | ||
} | ||
const nonMatchingProps = []; | ||
const parseWaitForPropDict = []; | ||
const nullProps = []; | ||
for (const prop of nullProps) { | ||
checkObjectPaths(e, prop, val => { | ||
if (val !== undefined && val !== null) { | ||
const p = prop.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Expected property `\" + p + \"` to not exist, found: `\" + val + \"`\"); | ||
return; | ||
} | ||
}, _notFound => { | ||
}); | ||
} | ||
for (const [parseWaitForPropKey, parseWaitForPropValue] of parseWaitForPropDict) { | ||
checkObjectPaths(e, parseWaitForPropKey, val => { | ||
if (val === undefined) { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
return; | ||
} | ||
if (val !== parseWaitForPropValue) { | ||
nonMatchingProps.push(\"expected `\" + parseWaitForPropValue + \"` for property `\" + parseWaitForPropKey + \"`, found `\" + val + \"`\"); | ||
} | ||
}, _notFound => { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
}); | ||
} | ||
return nonMatchingProps; | ||
}); | ||
} | ||
const timeLimit = page.getDefaultTimeout(); | ||
const timeAdd = 50; | ||
let allTime = 0; | ||
let parseWaitForProp = null; | ||
while (true) { | ||
while (true) { | ||
parseWaitForProp = await page.$$(\"a\"); | ||
if (parseWaitForProp.length !== 0) { | ||
parseWaitForProp = parseWaitForProp[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\"); | ||
} | ||
} | ||
const nonMatchingProps = await checkPropForElem(parseWaitForProp); | ||
if (nonMatchingProps.length !== 0) { | ||
break; | ||
} | ||
await new Promise(r => setTimeout(r, timeAdd)); | ||
if (timeLimit === 0) { | ||
continue; | ||
} | ||
allTime += timeAdd; | ||
if (allTime >= timeLimit) { | ||
const props = nonMatchingProps.join(\", \"); | ||
throw new Error(\"All properties still match\"); | ||
} | ||
}""", | ||
] | ||
wait = false | ||
warnings = [ | ||
] | ||
checkResult = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
instructions = [ | ||
"""async function checkPropForElem(elem) { | ||
return await elem.evaluate(e => { | ||
function checkObjectPaths(object, path, callback, notFoundCallback) { | ||
const found = []; | ||
for (const subPath of path) { | ||
found.push(subPath); | ||
if (object === undefined || object === null) { | ||
notFoundCallback(found); | ||
return; | ||
} | ||
object = object[subPath]; | ||
} | ||
callback(object); | ||
} | ||
const nonMatchingProps = []; | ||
const parseWaitForPropDict = [[[\"x\"],\"1\"]]; | ||
const nullProps = []; | ||
for (const prop of nullProps) { | ||
checkObjectPaths(e, prop, val => { | ||
if (val !== undefined && val !== null) { | ||
const p = prop.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Expected property `\" + p + \"` to not exist, found: `\" + val + \"`\"); | ||
return; | ||
} | ||
}, _notFound => { | ||
}); | ||
} | ||
for (const [parseWaitForPropKey, parseWaitForPropValue] of parseWaitForPropDict) { | ||
checkObjectPaths(e, parseWaitForPropKey, val => { | ||
if (val === undefined) { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
return; | ||
} | ||
if (val !== parseWaitForPropValue) { | ||
nonMatchingProps.push(\"expected `\" + parseWaitForPropValue + \"` for property `\" + parseWaitForPropKey + \"`, found `\" + val + \"`\"); | ||
} | ||
}, _notFound => { | ||
const p = parseWaitForPropKey.map(p => `\"${p}\"`).join('.'); | ||
nonMatchingProps.push(\"Property `\" + p + \"` doesn't exist\"); | ||
}); | ||
} | ||
return nonMatchingProps; | ||
}); | ||
} | ||
const timeLimit = page.getDefaultTimeout(); | ||
const timeAdd = 50; | ||
let allTime = 0; | ||
let parseWaitForProp = null; | ||
while (true) { | ||
while (true) { | ||
parseWaitForProp = await page.$$(\"a\"); | ||
if (parseWaitForProp.length !== 0) { | ||
parseWaitForProp = parseWaitForProp[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\"); | ||
} | ||
} | ||
const nonMatchingProps = await checkPropForElem(parseWaitForProp); | ||
if (nonMatchingProps.length !== 0) { | ||
break; | ||
} | ||
await new Promise(r => setTimeout(r, timeAdd)); | ||
if (timeLimit === 0) { | ||
continue; | ||
} | ||
allTime += timeAdd; | ||
if (allTime >= timeLimit) { | ||
const props = nonMatchingProps.join(\", \"); | ||
throw new Error(\"All properties still match\"); | ||
} | ||
}""", | ||
] | ||
wait = false | ||
warnings = [ | ||
] | ||
checkResult = true |
Oops, something went wrong.