1

Hi I need to click hover element in Selenium Python.

I tried to use action chains and then move to element but it didn't work for me.

My Selenium code Snippet:

element1= self.driver.find_element_by_css_selector("#layout-center .ui-tabs-nav.ui-helper-reset.ui-helper-clearfix.ui-widget-header.ui-corner-all.ui-sortable")

element2=self.driver.find_element_by_css_selector("#layout-center button.add-widget")
ac(driver).move_to_element(element1).click(element2).perform()

In the picture you can see how it looks in html code. Button to click

4
  • If you want hover, why you perform click? Commented May 31, 2017 at 14:06
  • element 2 is visible after hover on element 1. I used Actions Chains for move and click in Java and it was working good. Now I need solution i Python because on geckodriver 16.1 and selenium 3.42 it doesn't work.
    – siutex
    Commented Jun 1, 2017 at 11:05
  • Please determine "didn't work". Any errors? What is happening - do you see the "hover" part working? Thanks.
    – alecxe
    Commented Jun 1, 2017 at 16:18
  • Using move to doesn't print any errors. The mouse cursor just didn't move.
    – siutex
    Commented Jun 5, 2017 at 6:53

1 Answer 1

2

I see you are trying to use move_to_element, which currently isn't supported in the marionette/gecko driver. You can track the implementation on their GitHub.

moveTo is not part of the W3C WebDriver spec, it would be a good idea to move to the actions API to support modern firefox.

2
  • Any solution to make mouse over element 1 to click element 2?
    – siutex
    Commented Jun 5, 2017 at 6:53
  • Use Chrome or Python's gtk.gdk.Display class
    – kirbycope
    Commented Jun 5, 2017 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.