0

Got stuck in capybara coding. appreciate any help on this.

I need to mouseover on source element to click on the target element link. Not finding a way to get it. need to use this in chrome browser only.

Tried the code below

source=ses.find('#source-link')

ses.driver.action.move_to(source).perform

ses.find('#child-link').click
Kyle Decot
  • 20,715
  • 39
  • 142
  • 263
Jennifer
  • 45
  • 1
  • 9
  • Is this the same as [How to emulate mouse hover with Capybara](http://stackoverflow.com/questions/9784118/how-to-emulate-mouse-hover-with-capybara) - ie do `source.hover`? The problem with the current code is that it is passing a Capybara element when a Selenium::WebDriver element is expected. – Justin Ko May 20 '16 at 14:44
  • I tried the code specified in the link, could not use code "profile.native_events = true" with the chrome browser. This is not defined in chrome. It is defined only firefox. – Jennifer May 20 '16 at 17:36

1 Answers1

1

If what you're trying to do is hover over #source-link and then click `#child-link' it should just be

sess.find('#source-link').hover
sess.find('#child-link').click

If that doesn't work for you then we need to know exactly what events are triggering the behavior you expect.

Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78
  • Thanks Tom! but this is working intermittently. the focus does not hold on the 'source link ' everytime. any other steps can add to have 'source link' focused ? – Jennifer May 21 '16 at 09:44
  • What error exactly do you get? If you have animations turned on then you might need to sleep a little bit between the two actions to allow the animated appear of the #child-link to occur. – Thomas Walpole May 21 '16 at 17:34