有许多类似的帖子都在问这个问题:
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
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会提供必要的帮助。
有什么想法吗?