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

0
0

Reading here ,there apparently used to be a RenderedWebElement class with a hover method.It,however,was exclusively for Java (Searched the python bindings documentation here to no avail) and has since been deprecated for Java.

A hover can’t be performed using action_chains(method list) nor by using a webelement(method list)object either.

Any ideas as to how to do this for python? Been here but it uses RenderedWebElement and hence doesn’t help too much.

Python 2.7,
Windows Vista,Selenium 2 ,Python Bindings

EDIT: There is a method “mouse_over” for a selenium.selenium.selenium object but i cannot figure a way to create an instance without having the stand-alone server running already.

Question has been answered: Please go through the comments of the reply marked as answer just in-case you have misconceptions like I did !

  • You must to post comments
0
0

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()
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website