简体   繁体   中英

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

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM