Ray
Ray

Reputation: 163

How to hover over an image using capybara and selenium

Ive been trying to write an automation test to hover over an image using just capybara and selenium. Once i can get it to hover over the image i would like to check that the image has changed ie through the background image using the css. After some research some people have been saying that the trigger method doesnt work with selenium so ive been trying different stuff like:

hover = driver.find_element(:css => "element")
  driver.move_to.(hover).perform

featured_promo = page.find(:xpath, '//*[@id = "btnCalendar"]')
  featured_promo.native.hover()

Both of these have not worked.

Any help or suggestions would be greatly appreciated.

Upvotes: 1

Views: 3105

Answers (2)

Pawel
Pawel

Reputation: 11

Referring to this page: http://selenium.googlecode.com/svn/trunk/docs/api/rb/Selenium/WebDriver/ActionBuilder.html
Your code should look probably like below:

element = driver.find_element(...)
driver.action.move_to(element).perform

Upvotes: 1

Xwris Stoixeia
Xwris Stoixeia

Reputation: 1861

Try this..

driver.mouse.move_to(hover)

Upvotes: 2

Related Questions