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

  • If you want hover, why you perform click? – Peter M. - stands for Monica May 31 '17 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 Jun 1 '17 at 11:05
  • Please determine "didn't work". Any errors? What is happening - do you see the "hover" part working? Thanks. – alecxe Jun 1 '17 at 16:18
  • Using move to doesn't print any errors. The mouse cursor just didn't move. – siutex Jun 5 '17 at 6:53
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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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