intern icon indicating copy to clipboard operation
intern copied to clipboard

Incorrect base coordinate for moveMouseTo offset

Open jason0x43 opened this issue 5 years ago • 2 comments

In Intern 4.x (and probably 5-pre), the base coordinate for the moveMouseTo command may be incorrect. According to the JWP spec, any offset should be relative to the top-left corner of the element. In at least Chrome and EdgeChromium, it has been reported that the offset is relative to the center of the element.

This is likely due to chromedriver using stricter W3C semantics, in which case the fallback code for /moveto would be used since W3C WebDriver doesn't support a /moveto endpoint.

jason0x43 avatar Feb 05 '20 14:02 jason0x43

A test like the following will reproduce the issue with Intern 4.8, Chrome 79, Selenium 3.141.59, and chromedriver 79.0.3945.36.

import { describe, it } from 'intern/lib/interfaces/bdd';

describe('clicking', () => {
	it('should offset from the top left', async ({ remote }) => {
		await remote.get('/tests/functional/page.html');
		const div = await remote.findByCssSelector('.clickarea');
		await remote.moveMouseTo(div, 0, 0);
		await remote.pressMouseButton();
		await remote.releaseMouseButton();
		await remote.sleep(5000);
	});
});

The gray box in the image below is div.clickarea; the green box inside of it is centered on the mouse click position.

Screen Shot 2020-02-05 at 10 16 55 AM

jason0x43 avatar Feb 05 '20 15:02 jason0x43

Possibly related to https://github.com/mozilla/geckodriver/issues/789 (and Firefox does exhibit the same behavior when using the /moveto endpoint).

jason0x43 avatar Feb 05 '20 15:02 jason0x43