Get Element Revealed By Hovering (Java)
To get an element that is only revealed by hovering on a different element, use the method moveToElement from the Actions library. This will move the driver's cursor to hover an element and from there you can find the element you need to retrieve the desired elements.
actions.moveToElement(driver.findElement(By.xpath("//a[@class='dropdown-toggle']"))).build().perform(); driver.findElement(By.xpath("//li[h5]//h5//a")).getText();
In order to do this you need to add the following line to your imports:
import org.openqa.selenium.interactions.Actions;
Leave a reply
Your email address will not be published. Required fields are marked*