diff --git a/src/worker/runner/test-runner/index.js b/src/worker/runner/test-runner/index.js index 67791e82c..6530c99d6 100644 --- a/src/worker/runner/test-runner/index.js +++ b/src/worker/runner/test-runner/index.js @@ -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) }); } }; diff --git a/test/src/worker/runner/test-runner/index.js b/test/src/worker/runner/test-runner/index.js index c008ade09..f6c835a66 100644 --- a/test/src/worker/runner/test-runner/index.js +++ b/test/src/worker/runner/test-runner/index.js @@ -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 }); + }); }); });