Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 9x 5x 4x 3x 3x 3x 3x | /**
*
* Move the mouse by an offset of the specified element. If no element is specified,
* the move is relative to the current mouse cursor. If an element is provided but
* no offset, the mouse will be moved to the center of the element. If the element
* is not visible, it will be scrolled into view.
*
* @param {Number=} xoffset X offset to move to, relative to the top-left corner of the element. If not specified, the mouse will move to the middle of the element.
* @param {Number=} yoffset Y offset to move to, relative to the top-left corner of the element. If not specified, the mouse will move to the middle of the element.
*
* @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidmoveto
* @type protocol
*/
import { getElementRect } from '../../utils'
export default async function moveTo (xoffset, yoffset) {
if (!this.isW3C) {
return this.moveToElement(this.elementId, xoffset, yoffset)
}
/**
* get rect of element
*/
const { x, y, width, height } = await getElementRect(this)
const newXoffset = parseInt(x + (typeof xoffset === 'number' ? xoffset : (width / 2)), 10)
const newYoffset = parseInt(y + (typeof yoffset === 'number' ? yoffset : (height / 2)), 10)
/**
* W3C way of handle the mouse move actions
*/
return this.performActions([{
type: 'pointer',
id: 'finger1',
parameters: { pointerType: 'mouse' },
actions: [{ type: 'pointerMove', duration: 0, x: newXoffset, y: newYoffset }]
}]).then(() => this.releaseActions())
}
|