从和到是 slider 中用于更改从和到时间的“按钮”。 我在如何在 webdriverio 中移动这些按钮时遇到问题。下面是我想要如何做到这一点的示例,但什么也没有发生。
let from = browser.element('#from');
let to = browser.element('#to');
var XCordinate = from.getLocation(); //gets current x position of from element
var yCordinate = from.getLocation(); //gets current y position of from element
from.moveToObject(XCordinate+20, yCordinate); //Move the element only in x
最佳答案
因为 moveToObject 函数只是将光标移动到该坐标,而不是单击那里或在那里执行任何操作。
您可以使用 webdriverio 的 buttonDown
、buttonUp
和 moveTo
方法,如下所示:
browser.buttonDown(button);
browser.moveTo(element,xoffset,yoffset);
browser.buttonUp(button);
关于javascript - 使用 webdriverio 在页面上移动选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52760615/