Skip to content

Commit

Permalink
fix: round xOffset and yOffset when resetting cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Jan 31, 2024
1 parent ae838b9 commit cea4e30
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/worker/runner/test-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ module.exports = class TestRunner {
const { x = 0, y = 0 } = await session.execute(function () {
return document.body.getBoundingClientRect();
});
await body.moveTo({ xOffset: -x, yOffset: -y });
// x and y must be integer, wdio will throw error otherwise
await body.moveTo({ xOffset: -Math.floor(x), yOffset: -Math.floor(y) });
}
};

Expand Down
8 changes: 8 additions & 0 deletions test/src/worker/runner/test-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,14 @@ describe("worker/runner/test-runner", () => {

assert.callOrder(body.scrollIntoView, body.moveTo);
});

it("should floor coords if body element has fractional coords", async () => {
browser.publicAPI.execute.resolves({ x: 10.123, y: 15.899 });

await run_();

assert.calledOnceWith(body.moveTo, { xOffset: -10, yOffset: -15 });
});
});
});

Expand Down

0 comments on commit cea4e30

Please sign in to comment.