1

Searching from many forums i got the code to hover the mouse over an element .I want to hover the mouse over a thumbnail image. i put html element ".thumbnail" as class inside find_element method .I dont know which parameter should i place inside find_element method?

My html element is given below.

<a class="thumbnail">
<span class="badgeFeatured">featured</span>
<img alt="" src="https://do3dm75n3e02m.cloudfront.net/arts/preview_3ds/14/original/open-uri20121128-5897-wh90rf_1354148717.png20121128-5897-194vld7-0?1354148717">
<p>Flourish Happy Birthday</p>
</a>


 el = driver.find_element(:class => "thumbnail")
driver.move_to.(el).perform

Due to this problem it does not move mouse over the thumbnail image.

divz
  • 7,847
  • 23
  • 55
  • 78
  • Look at the answers in this question - http://stackoverflow.com/questions/9784118/how-to-emulate-mouse-hover-with-capybara. Your previous question was closed as a duplicate of this one – Andrei Botalov May 17 '13 at 07:23
  • hey question is almost similar.but i think you didnt check what i asked.my question is " I don't know which parameter should I place inside find_element method?" can you answer for this? – divz May 17 '13 at 07:39
  • Look at [this](https://code.google.com/p/selenium/wiki/RubyBindings#API_Example). It should be `find_element(:class, "thumbnail")`, not `find_element(:class => "thumbnail")` – Andrei Botalov May 17 '13 at 07:59
  • why it is showing undefined local variable driver? – divz May 17 '13 at 08:09
  • because capybara provides native access to underlying selenium driver via `page.driver.browser`, not via `driver` – Andrei Botalov May 17 '13 at 08:23
  • i don't know what you want to do – Andrei Botalov May 17 '13 at 08:25
  • i include require 'selenium-webdriver' and how caan i define a local variable for driver – divz May 17 '13 at 08:26

1 Answers1

1

In Webdriver(java), we can perform mouse over action like this:

Actions actions = new Actions(driver);
WebElement imageSpan = driver.findElement(By.className("badgeFeatured"));
actions.moveToElement(imageSpan);
Minal K Sinha
  • 424
  • 2
  • 6