2

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);
})
MBielski
  • 6,628
  • 3
  • 32
  • 43

1 Answers1

1

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).

C Snover
  • 17,908
  • 5
  • 29
  • 39
  • If I provide the offset values everything is fine. `return Remote.moveMouseTo(element, 0, 0);` works like a charm. – MBielski Dec 10 '15 at 19:51
  • Look at the parameters that are being sent to the server in that case. Do they actually include an element, or only xoffset and yoffset? – C Snover Dec 10 '15 at 19:54
  • Ok, will do, but it might take me a bit to get back to you. – MBielski Dec 10 '15 at 19:54
  • Actually you might as well just inspect what the type of `element` is when you make the call… – C Snover Dec 10 '15 at 19:59
  • The value of `typeof element` is function, which seems odd to me. Updating the info in the question to include how `contextMenu.Options.Actions.element` is defined. – MBielski Dec 10 '15 at 21:36
  • Ok, now I'm confused, because in this question (http://stackoverflow.com/questions/34099116/events-after-clickmousebutton) you suggested referencing the elements that way and it worked fine as long as I was providing offsets. Now that I am trying something where the offsets are not provided it doesn't work and you're saying that what you suggested I do previously can't be serialised into JSON so it won't work? "Norman, Norman... coordinate." – MBielski Dec 10 '15 at 21:49
  • Ok, wait... I'm doing something wrong there. Let me fix that and see what comes. – MBielski Dec 10 '15 at 21:50
  • Ok, changing that reference changes what is passed to moveMouseTo and makes it all work. Not sure why I wrote the test code the wrong way, but fixing it solves the issue. I might also note that I think that because the element was wrong, Intern/Leadfoot was trying its best to move the mouse to where I wanted when I provided offsets, and that is what threw me off. – MBielski Dec 10 '15 at 22:05