Is there a way to perform a mouseover (hover over an element) using Selenium and Python bindings?

To do a hover you need to use the move_to_element method.

Here is an example

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

firefox = webdriver.Firefox()
firefox.get('http://foo.bar')
element_to_hover_over = firefox.find_element_by_id("baz")

hover = ActionChains(firefox).move_to_element(element_to_hover_over)
hover.perform()

Leave a Comment