当元素存在时,将鼠标移到需要X/Y偏移的位置

Leadfoot moveMouseTo requiring X/Y offsets when element is present

本文关键字:位置 存在 元素 鼠标      更新时间:2023-09-26

在leadfoot命令#moveMouseTo的文档中,它声明每个参数都是可选的(https://theintern.github.io/leadfoot/Command.html#moveMouseTo)。当我传入一个元素而不传入X或Y偏移时,我会得到一个关于需要存在偏移的命令的错误。

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'

这是有问题的代码:

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

contextMenu.Options.Actions.element定义为:

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

根据文档,这应该将鼠标移动到传递的元素的中心。显然,这并没有发生。我是不是做错了什么?这是不是没有正确记录,或者这是Leadfoot中的一个错误?

编辑测试代码的正确格式是:

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

根据您在这里提供的信息,contextMenu.Options.Actions.elementundefined或其他无法序列化为JSON的类型(如function)。