Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cypress/integration/click.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ describe("cy.realClick", () => {
.realClick({ clickCount: 2 });
});

it("should dispatch multiple clicks with clickCount greater than 1", (done) => {
let count = 0
cy.get(".action-btn")
.then(($button) => {
$button.get(0).addEventListener("click", () => {
count++
if (count === 2) {
done()
}
});
})
.realClick({ clickCount: 2 });
});

describe("scroll behavior", () => {
function getScreenEdges() {
const cypressAppWindow = window.parent.document.querySelector("iframe")
Expand Down
41 changes: 23 additions & 18 deletions src/commands/realClick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,30 @@ export async function realClick(
});

log.snapshot("before");
await fireCdpCommand("Input.dispatchMouseEvent", {
type: "mousePressed",
x,
y,
clickCount: options.clickCount ?? 1,
buttons: 1,
pointerType: options.pointer ?? "mouse",
button: options.button ?? "left",
});

await fireCdpCommand("Input.dispatchMouseEvent", {
type: "mouseReleased",
x,
y,
clickCount: options.clickCount ?? 1,
buttons: 1,
pointerType: options.pointer ?? "mouse",
button: options.button ?? "left",
});
const { clickCount = 1 } = options

for (let currentClick = 1; currentClick <= clickCount; currentClick++) {
await fireCdpCommand("Input.dispatchMouseEvent", {
type: "mousePressed",
x,
y,
clickCount: currentClick,
buttons: 1,
pointerType: options.pointer ?? "mouse",
button: options.button ?? "left",
});

await fireCdpCommand("Input.dispatchMouseEvent", {
type: "mouseReleased",
x,
y,
clickCount: currentClick,
buttons: 1,
pointerType: options.pointer ?? "mouse",
button: options.button ?? "left",
});
}

log.snapshot("after").end();

Expand Down