From c837bfe95821ad670f3581c76e73b7481854d8ce Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 5 Feb 2025 16:17:30 +0100 Subject: [PATCH 1/2] Fix click with coordinates --- src/commands/input.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/input.js b/src/commands/input.js index 29414417..2624669d 100644 --- a/src/commands/input.js +++ b/src/commands/input.js @@ -35,7 +35,7 @@ function parseClick(parser) { const tuple = p.entries; return { 'instructions': [ - `await page.click(${tuple[0].value.value}, ${tuple[1].value.value});`, + `await pages[0].mouse.click(${tuple[0].value.value}, ${tuple[1].value.value});`, ], }; } From 05a2a39b7c36da9144d97c630fa68e7c9ff51587 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 5 Feb 2025 16:17:46 +0100 Subject: [PATCH 2/2] Add new test for click command and update API tests --- tests/api-output/parseClick/multiline-3.toml | 2 +- tests/api-output/parseClick/pos-1.toml | 2 +- tests/api-output/parseClick/pos-2.toml | 2 +- tests/ui/click.goml | 7 +++++++ tests/ui/click.output | 5 +++++ 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 tests/ui/click.goml create mode 100644 tests/ui/click.output diff --git a/tests/api-output/parseClick/multiline-3.toml b/tests/api-output/parseClick/multiline-3.toml index 113e33fa..2aedfc7b 100644 --- a/tests/api-output/parseClick/multiline-3.toml +++ b/tests/api-output/parseClick/multiline-3.toml @@ -1,3 +1,3 @@ instructions = [ - """await page.click(1, 2);""", + """await pages[0].mouse.click(1, 2);""", ] diff --git a/tests/api-output/parseClick/pos-1.toml b/tests/api-output/parseClick/pos-1.toml index 113e33fa..2aedfc7b 100644 --- a/tests/api-output/parseClick/pos-1.toml +++ b/tests/api-output/parseClick/pos-1.toml @@ -1,3 +1,3 @@ instructions = [ - """await page.click(1, 2);""", + """await pages[0].mouse.click(1, 2);""", ] diff --git a/tests/api-output/parseClick/pos-2.toml b/tests/api-output/parseClick/pos-2.toml index 113e33fa..2aedfc7b 100644 --- a/tests/api-output/parseClick/pos-2.toml +++ b/tests/api-output/parseClick/pos-2.toml @@ -1,3 +1,3 @@ instructions = [ - """await page.click(1, 2);""", + """await pages[0].mouse.click(1, 2);""", ] diff --git a/tests/ui/click.goml b/tests/ui/click.goml new file mode 100644 index 00000000..578d3532 --- /dev/null +++ b/tests/ui/click.goml @@ -0,0 +1,7 @@ +// Ensure that `click` works for both coordinates and selector. +go-to: "file://" + |CURRENT_DIR| + "/" + |DOC_PATH| + "/elements.html" +store-position: ("#js-call", {"x": x, "y": y}) +click: (|x|, |y|) +wait-for-css-false: ("#js-call", {"margin-top": "0px"}) +click: "#the-input" +assert: "#the-input" diff --git a/tests/ui/click.output b/tests/ui/click.output new file mode 100644 index 00000000..cf12ac29 --- /dev/null +++ b/tests/ui/click.output @@ -0,0 +1,5 @@ +=> Starting doc-ui tests... + +click... OK + +<= doc-ui tests done: 1 succeeded, 0 failed \ No newline at end of file