简体   繁体   English

使用水豚在硒红宝石中悬停鼠标

[英]Mouse Hover in selenium Ruby using capybara

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? 我将html元素".thumbnail"作为class放置在find_element方法内。我不知道应该在find_element方法内放置哪个参数?

My html element is given below. 我的html元素如下。

<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. 由于此问题,它不会将鼠标移到缩略图上。

In Webdriver(java), we can perform mouse over action like this: 在Webdriver(java)中,我们可以像这样执行鼠标悬停操作:

Actions actions = new Actions(driver);
WebElement imageSpan = driver.findElement(By.className("badgeFeatured"));
actions.moveToElement(imageSpan);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM