Get Element Revealed By Hovering (Python)

Get Element Revealed By Hovering (Python)

To get an element that is only revealed by hovering on a different element, use the method move_to_element from the ActionChains 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:

from selenium.webdriver.common.action_chains import ActionChains

See Working Example



Using Java

Leave a reply

Your email address will not be published. Required fields are marked*

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.