codeceptjs / CodeceptJS

Supercharged End 2 End Testing Framework for NodeJS
http://codecept.io
MIT License
4.11k stars 724 forks source link

Change WebDriver.IO moveCursorTo behaviour to auto-center on element #2348

Open axheim opened 4 years ago

axheim commented 4 years ago

Issue

WebDriver.IO moveCursorTo does not auto-center on element as default

Issue Details

Current implementation of WebDriver.IO moveCursorTo uses 0,0 as default offsets for x,y coordinates.

In some situations this can cause problems, if hovering actions are implemented on both parent and child element. Having moved the mouse to 0,0 coordinate of the child causes the browser sometimes to trigger hover event of the parent instead of the child at 0,0 coordinate.

Expected behaviour

Better default behaviour would be to calculate size of the target element and automatically move coursor to the center of this element, instead of the 0,0 corner to improve robustness.

Environment Details

mirao commented 4 years ago

It would be useful. Also as a user I typically click to the center of buttons, not to point 0,0 Now I have to call moveCursorTo() with offsetX and offsetY = 5 in my WebDriver tests otherwise the tests often fail (sometimes in Chrome, sometimes in Firefox, sometimes in both browsers).