-
-
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 #594 from GuillaumeGomez/store-property
Add support for object-path in `store-property` command
- Loading branch information
Showing
14 changed files
with
349 additions
and
100 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
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,47 @@ | ||
instructions = [ | ||
"""let elem = await page.$(\"a\"); | ||
if (elem === null) { throw '\"a\" not found'; } | ||
const jsHandle = await elem.evaluateHandle(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 props = [[[\"ye\",\"ya\"], \"a\"]]; | ||
const ret = []; | ||
const errors = []; | ||
for (const [prop, varName] of props) { | ||
checkObjectPaths(e, prop, found => { | ||
if (found === undefined) { | ||
const p = prop.map(p => `\"${p}\"`).join('.'); | ||
errors.push('\"No property named `' + p + '`\"'); | ||
return; | ||
} | ||
ret.push([found, varName]); | ||
}, _ => { | ||
const p = prop.map(p => `\"${p}\"`).join('.'); | ||
errors.push('\"No property named `' + p + '`\"'); | ||
}); | ||
} | ||
if (errors.length !== 0) { | ||
throw \"The following errors happened: [\" + errors.join(\", \") + \"]\"; | ||
} | ||
return ret; | ||
}); | ||
const data = await jsHandle.jsonValue(); | ||
for (const [found, varName] of data) { | ||
arg.setVariable(varName, found); | ||
}""", | ||
] | ||
wait = false | ||
warnings = [ | ||
] |
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,47 @@ | ||
instructions = [ | ||
"""let elem = await page.$(\"a\"); | ||
if (elem === null) { throw '\"a\" not found'; } | ||
const jsHandle = await elem.evaluateHandle(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 props = [[[\"ye\",\"ya\"], \"a\"],[[\"yo\"], \"b\"]]; | ||
const ret = []; | ||
const errors = []; | ||
for (const [prop, varName] of props) { | ||
checkObjectPaths(e, prop, found => { | ||
if (found === undefined) { | ||
const p = prop.map(p => `\"${p}\"`).join('.'); | ||
errors.push('\"No property named `' + p + '`\"'); | ||
return; | ||
} | ||
ret.push([found, varName]); | ||
}, _ => { | ||
const p = prop.map(p => `\"${p}\"`).join('.'); | ||
errors.push('\"No property named `' + p + '`\"'); | ||
}); | ||
} | ||
if (errors.length !== 0) { | ||
throw \"The following errors happened: [\" + errors.join(\", \") + \"]\"; | ||
} | ||
return ret; | ||
}); | ||
const data = await jsHandle.jsonValue(); | ||
for (const [found, varName] of data) { | ||
arg.setVariable(varName, found); | ||
}""", | ||
] | ||
wait = false | ||
warnings = [ | ||
] |
Oops, something went wrong.