如何使用黄瓜/红宝石悬停在元素上以使其可见,以便我可以单击链接?

时间:2012-11-13 03:33:57

标签: ruby-on-rails selenium cucumber capybara

页面有产品,当我将鼠标悬停在图像上时,它会显示产品数量并立即购买按钮。我想在鼠标悬停后点击数量并立即购买按钮。

driver.navigate.to('http://testsite/')   

product = driver.find_element(:xpath, "//div[@id='recipes-inspiration-menu']")
submenu = driver.find_element(:xpath, "//li[@class='first first-child  children']")

driver.find_element(:xpath, "//a[@title='placed']").click

1 个答案:

答案 0 :(得分:2)

试试这个(这只适用于使用jquery的网站)。

driver.execute_script('$("#element").trigger("hover")')