Free Source Code and Tutorials

Custom Search

How to mouse hover on a web element using WebDriver?

How to mouse hover on a web element using WebDriver?

Now a days mouse hover functionality is used by most of the developers in web application development. So it is very much important to automate this functionality too without which testing is incomplete.

WebDriver offers a wide range of interaction utilities that the user can use to automate mouse and keyboard events. Action Interface is one such utility which simulates the single user interactions.

Thus, In the following scenario, we have used Action Interface to mouse hover on a drop down which then opens a list of options.

Sample Code:

  1. // Instantiating Action Interface
  3. Actions actions=new Actions(driver);
  5. // howering on the dropdown
  7. actions.moveToElement(driver.findElement("id of the dropdown"))).perform();
  9. // Clicking on one of the items in the list options
  10. WebElement subLinkOption=driver.findElement("id of the sub link"));
Facebook Comments
(Visited 1 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!

%d bloggers like this: