Search code examples
javascriptinternleadfoot

Leadfoot moveMouseTo requiring X/Y offsets when element is present


In the docs for leadfoot Command#moveMouseTo it states that every argument is optional (https://theintern.github.io/leadfoot/Command.html#moveMouseTo). When I pass in an element without passing in X or Y offsets, I get an error about the command requiring the offsets to be present.

message: [POST http://localhost:4444/wd/hub/session/62d8467c-21d9-4565-bc9d-e527c91dc61d/moveto / {}] Missing parameters: element, xoffset, yoffset (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'

Here's the code in question:

.then(function () {
    return contextMenu.Options.Actions.element;
})
.then(function (element) {
    return Remote.moveMouseTo(element);
})

contextMenu.Options.Actions.element is defined as:

return Remote
    .setFindTimeout(5000)
    .findByXpath('/html/body/table[1]/tbody/tr[2]');

According to the docs, this should move the mouse to the center of the passed element. Obviously, that isn't happening. Am I doing something the wrong way? Is this not documented correctly, or is this a bug in Leadfoot?

EDIT The correct format for the test code is:

.then(contextMenu.Options.Actions.element)
.then(function (element) {
    return Remote.moveMouseTo(element);
})

Solution

  • Based on what I can see from the information you’ve given here, contextMenu.Options.Actions.element is undefined or some other type that cannot be serialised to JSON (like function).