Mouse hover functionality check using selenium

Posted By : Ruhi Chauhan | 31-Oct-2018

Mouse hover functionality check using selenium

 

When you perform the automation Testing, you will see some scenarios where value shows when you hover the mouse arrow on the text.

By reading this blog you will get to know how you can click on the list of values by using the Selenium webdriver.

We can do this with the help of the ACTIONS class, it is a class present in the selenium webdriver.

By using this class we can perform the click event and able to click on the list which is showing when we are hovering over the text.

Actions is a class, we will use the moveToElement method of the ACTIONS class

There is a syntax which we follow when we use the Class ACTIONS

When we use the methods of the ACTIONS class we use Build(). Perform() at the end

So please make a note whenever we use the ACTIONS class and when we use the methods of the class we need to use the Build(). Perform() at the end

Steps to find the hovered element on the web page:-

  1. The first step is to identify the element which is hovered on the page
  2. Now in this step, we will use the Selenium WebDriver


Below is the code for the same:-

System.setProperty("webdriver.chrome.driver", "/home/ruhi/chromedriver");
    WebDriver driver=new ChromeDriver();
    driver.get("http://google.com");
    driver.findElement(By.xpath("//*[@id=\"dropdownMenu1\"]")).click();
   WebElement element= driver.findElement(By.linkText("ETH"));
   Actions action = new Actions(driver);
   action.moveToElement(element).build().perform();
   WebElement subElement= driver.findElement(By.linkText("ETH/LTC"));
   action.moveToElement(subElement).perform();


 

Related Tags

About Author

Author Image
Ruhi Chauhan

Ruhi is a QA Engineer with expertise in manual testing and she loves Travelling and Dancing.

Request for Proposal

Name is required

Comment is required

Sending message..