I use Selenium 2 WebDriver on Ruby.
How it is possible click on hidden link, with css (display: none)? the link is submenu and is visible when mouse over on menu.>
In the past, if I have not had much luck with the ActionBuilder methods, I just use pure javascript:
def mouse_over_and_out(element)
@driver.execute_script("if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('mouseover', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('onmouseover');}", element)
yield element
@driver.execute_script("if(document.createEvent){var evObj = document.createEvent('MouseEvents');evObj.initEvent('mouseout', true, false); arguments[0].dispatchEvent(evObj);} else if(document.createEventObject) { arguments[0].fireEvent('onmouseout');}", element)
end
def wait_for_visibility(element)
wait = Selenium::WebDriver::Wait.new(:timeout => 15)
wait.until do
element.visible?
end
element
end
mouse_over_and_out(@driver.find_element(:css => "ul#nav-main li")) do |menu|
submenu = menu.find_element(:css => "ul li a")
wait_for_visibility(submenu).click
end