nodejs/selenium webdriver: Can't move mouse to a required position

最后都变了- 提交于 2021-02-04 08:30:08

问题


I'm having trouble in moving mouse pointer in chrome webdriver to a required position in nodejs. I'm using -selenium webdriver 4.0.0-alpha.1.

This is how i'm building the driver

const {Builder,By} = require("selenium-webdriver");
let driver = new Builder().forBrowser('chrome').build();

This is where i'm defining the logic to move mouse to a position named value = { x: 262, y: 315 }

await driver.wait(until.elementLocated(By.className("OUeyt")));
let a = driver.findElement(By.className("_3Bxar"));
let actions = driver.actions({bridge: true});
await actions.mouseMove(a, value).click().perform();

Whenever i run this part, it says mousemove() is not a function. I've tried what the docs say to no avail. On stackoverflow, the solutions are present but for Java and i HAVE to do it in JavaScript. What can i do to perform this functionality?


回答1:


driver.action().mouseMove() was deprecated in v4.0.0-alpha1. Check out this link: https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/input_exports_Actions.html




回答2:


mouseMove() in actions api of latest version of selenium-webdriverjs is depricated for chrome. You can revert back to version 3.6.0 if you still want to use it.

As alternatives, you can use execute/executeScript or directly from

https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/input_exports_Actions.html



来源:https://stackoverflow.com/questions/51465187/nodejs-selenium-webdriver-cant-move-mouse-to-a-required-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!