问题
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