如何使用Selenium悬停在元素上以使其可见,以便我可以单击链接?

时间:2012-08-01 15:51:56

标签: ruby-on-rails ruby-on-rails-3 selenium rspec

有许多类似的帖子都在问这个问题:

How to hover over (mouseover) an element in Selenium Ruby?

Selenium2 WebDriver Ruby => how click on a hidden link

Ruby Mouse Over is not long enough, may need a delay of some sort

Code for mouse over action.

div.rating-panel隐藏div.empty-stars-container,直到div.empty-stars-container悬停。我想模拟悬停在div.rating-panel上方的用户,然后点击it "should create rating items" , :js => true do # wait = Selenium::WebDriver::Wait.new(:timeout => 10) # seconds empty_stars = page.driver.browser.find_element(:css, "h1 .empty-stars-container") star_3 = page.driver.browser.find_element(:css, "h1 a#panel_1_star_3") new_save = page.driver.browser.find_element(:css, "input#new_save") page.driver.browser.action.move_to(empty_stars).perform # wait.until { star_3.displayed? == true } star_3.click new_save.click page.should have_css("div.user-stars-container") end 中的几个链接。

move_to

浏览器打开,执行wait.until操作(我假设),但面板永远不会显示!我尝试star_3.click,但这只是导致超时。

测试在Element is not currently visible and so may not be interacted with 失败并显示错误消息

{{1}}

我希望有办法做我想做的事情,因为我的应用程序中有很多javascript测试,我希望Selenium会提供必要的帮助。

有什么想法吗?

0 个答案:

没有答案