I am writing a selenium test in Javascript, where I want to move/hover cursor over a particular element. I tried bunch of things, but nothing seems to work -

1. driver.findElement(selector)
      .then(element => driver.actions().move({origin:element}).perform())
2. driver.findElement(selector)
      .then(element => driver.actions().moveToElement(element).perform())
3. driver.findElement(selector)
      .then(element => driver.actions({bridge: true}).moveMouse(element).perform())
4. driver.findElement(selector)
      .then(element => driver.actions({bridge: true}).move(element).clickAndHold().perform())
5. driver.findElement(selector)
      .then(element => driver.actions({bridge:true}).move({duration:5000,origin:element,x:0,y:0}).perform())

I am consuming 3.6.0 version of selenium-webdriver npm package.

Note - I am able to perform rest all driver actions like click, DoubleClick etc on that element, so essentially there are no issues in discovering that element. Just move action I am unable to perform - it is always giving TypeError: driver.actions(...).move is not a function

3 Answers 3

const {
} = require('selenium-webdriver');

let driver = new Builder()
    .setChromeOptions( /* ... */ )
    .setFirefoxOptions( /* ... */ )

driver.get("https://www.google.com/search?q=s&oq=s&aqs=chrome..69i57.210j0j15&sourceid=chrome&ie=UTF-8").then((test) => {

    driver.wait(until.elementLocated((By.css('div[role="dialog"] iframe')), 20000)).then((elemframe) => {

            driver.wait(until.elementLocated(By.xpath('(//*[contains(text(),"I agree")])[1]')), 20000).then((elem) => {

                    x: 0,
                    y: 0,
                    origin: elem


Use latest npm release as the legacy action class doesn't have move in it .


else use mouseMove

  • Thanks much! This helps. Commented Mar 31, 2021 at 13:00
  • Please accept the answer by clicking the tick sign thank you :)
    – PDHide
    Commented Mar 31, 2021 at 13:07
const hoverLocation = driver.findElement(selector);
const actions = driver.actions({ bridge: true });
actions.move({ origin: hoverLocation }).perform();

Find your hover location, then you can perform the action over that location.


I have found the solution, We should change moveElement() to executeScript("arguments[0].scrollIntoView(true);", element) Here is the complete replacement:

const element = await driver.findElement(...)
await driver.executeScript("arguments[0].scrollIntoView(true);", element)
await sleep(500);

And sleep function:

function sleep(ms) {return new Promise(resolve => setTimeout(resolve, ms))}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.