Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
36 lines (29 sloc) 1.16 KB
layout title date excerpt categories
post
WebDriverJS: Hover over element
2017-11-22 20:23:14 -4000
How to hover over an element with WebDriverJS (Selenium Webdriver for Node.js).
selenium webdriver webdriverjs nodejs javascript

Assuming you have a [driver]({% post_url 2016/2016-11-25-webdriverjs-launch-browser %}) launched and found the following WebElement:

const myElement = driver.findElement({ css: '#myElement' });

You can hover over it using the mouseMove action sequence:

driver
  .actions()
  .mouseMove(myElement)
  .perform();

Alternatively, you could move the mouse over the element location:

myElement
  .getLocation()
  .then(location => {
    driver
      .actions()
      .mouseMove(location)
      .perform();
  });