gpt4 book ai didi

javascript - 如何使用 Protractor/Selenium 将鼠标移动到任意点

转载 作者:行者123 更新时间:2023-12-03 13:22:08 26 4
gpt4 key购买 nike

是否可以将鼠标移动到屏幕上的任意坐标/相对于 Protractor 测试中的元素?我看到人们建议 Java 用户使用 Robot,但我当然不能在 JavaScript 中使用它。

最佳答案

我自己想通了……只是通过 Protractor 和 Selenium 文档进行了深入挖掘。这是一些示例代码:

  it('should pan plots when you click and drag', function() {
var plot0 = element(by.css('.plot > canvas'));
browser.actions()
.mouseMove(plot0, {x: 100, y: 100}) // 100px from left, 100 px from top of plot0
.mouseDown()
.mouseMove({x: 400, y: 0}) // 400px to the right of current location
.perform();
});

关于javascript - 如何使用 Protractor/Selenium 将鼠标移动到任意点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28705613/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com