-
-
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 #623 from GuillaumeGomez/set-cmds
Allow to have boolean values in set-property and set-attribute commands
- Loading branch information
Showing
14 changed files
with
92 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
instructions = [ | ||
"""const parseSetAttributeElem = await page.$(\"a\"); | ||
if (parseSetAttributeElem === null) { throw '\"a\" not found'; } | ||
await page.evaluate(e => { | ||
e.setAttribute(\"b\",true); | ||
}, parseSetAttributeElem);""", | ||
] |
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,7 @@ | ||
instructions = [ | ||
"""const parseSetAttributeElem = await page.$(\"a\"); | ||
if (parseSetAttributeElem === null) { throw '\"a\" not found'; } | ||
await page.evaluate(e => { | ||
e.setAttribute(\"b\",12); | ||
}, parseSetAttributeElem);""", | ||
] |
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 |
---|---|---|
@@ -1 +1 @@ | ||
error = """type \"json\" (`{\"a\": \"x\"}`) is not allowed as value in this JSON dict, allowed types are: [`ident`, `number`, `string`] (second element of the tuple)""" | ||
error = """type \"json\" (`{\"a\": \"x\"}`) is not allowed as value in this JSON dict, allowed types are: [`boolean`, `ident`, `number`, `string`] (second element of the tuple)""" |
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 |
---|---|---|
@@ -1 +1 @@ | ||
error = """type \"array\" (`[\"a\"]`) is not allowed as value in this JSON dict, allowed types are: [`ident`, `number`, `string`] (second element of the tuple)""" | ||
error = """type \"array\" (`[\"a\"]`) is not allowed as value in this JSON dict, allowed types are: [`boolean`, `ident`, `number`, `string`] (second element of the tuple)""" |
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 @@ | ||
error = """type \"boolean\" (`true`) is not allowed as value in this JSON dict, allowed types are: [`number`, `string`] (second element of the tuple)""" |
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,7 @@ | ||
instructions = [ | ||
"""const parseSetCssElem = await page.$(\"a\"); | ||
if (parseSetCssElem === null) { throw '\"a\" not found'; } | ||
await page.evaluate(e => { | ||
e.style[\"b\"] = \"12\"; | ||
}, parseSetCssElem);""", | ||
] |
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,24 @@ | ||
instructions = [ | ||
"""const parseSetPropertyElem = await page.$(\"a\"); | ||
if (parseSetPropertyElem === null) { throw '\"a\" not found'; } | ||
await page.evaluate(e => { | ||
function setObjValue(object, path, value) { | ||
for (let i = 0; i < path.length - 1; ++i) { | ||
const subPath = path[i]; | ||
if (object[subPath] === undefined || object[subPath] === null) { | ||
if (value === undefined) { | ||
return; | ||
} | ||
object[subPath] = {}; | ||
} | ||
object = object[subPath]; | ||
} | ||
if (value === undefined) { | ||
delete object[path[path.length - 1]]; | ||
} else { | ||
object[path[path.length - 1]] = value; | ||
} | ||
} | ||
setObjValue(e, [\"b\"], true); | ||
}, parseSetPropertyElem);""", | ||
] |
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,24 @@ | ||
instructions = [ | ||
"""const parseSetPropertyElem = await page.$(\"a\"); | ||
if (parseSetPropertyElem === null) { throw '\"a\" not found'; } | ||
await page.evaluate(e => { | ||
function setObjValue(object, path, value) { | ||
for (let i = 0; i < path.length - 1; ++i) { | ||
const subPath = path[i]; | ||
if (object[subPath] === undefined || object[subPath] === null) { | ||
if (value === undefined) { | ||
return; | ||
} | ||
object[subPath] = {}; | ||
} | ||
object = object[subPath]; | ||
} | ||
if (value === undefined) { | ||
delete object[path[path.length - 1]]; | ||
} else { | ||
object[path[path.length - 1]] = value; | ||
} | ||
} | ||
setObjValue(e, [\"b\"], 12); | ||
}, parseSetPropertyElem);""", | ||
] |
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 |
---|---|---|
@@ -1 +1 @@ | ||
error = """type \"json\" (`{\"a\": \"x\"}`) is not allowed as value in this JSON dict, allowed types are: [`ident`, `number`, `string`] (second element of the tuple)""" | ||
error = """type \"json\" (`{\"a\": \"x\"}`) is not allowed as value in this JSON dict, allowed types are: [`boolean`, `ident`, `number`, `string`] (second element of the tuple)""" |
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 |
---|---|---|
@@ -1 +1 @@ | ||
error = """type \"array\" (`[\"a\"]`) is not allowed as value in this JSON dict, allowed types are: [`ident`, `number`, `string`] (second element of the tuple)""" | ||
error = """type \"array\" (`[\"a\"]`) is not allowed as value in this JSON dict, allowed types are: [`boolean`, `ident`, `number`, `string`] (second element of the tuple)""" |
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