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
We can do this with the help of the ACTIONS class, it is a class present in the selenium
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:-
- The first step is to identify the element which is
hovered on the page - 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();
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Ruhi Chauhan
Ruhi is a QA Engineer with expertise in manual testing and she loves Travelling and Dancing.