When clicking a link that opens a new page, I've found it
nesacery to wait_for_page_to_load before asserting anything about
it. However, some links in the app I am working on open an iframe,
and I need to wait for those to load too. To achive this, I have
implemented this hack in selenium_session.rb:
def click_link(link_text_or_regexp, options = {})
if link_text_or_regexp.is_a?(Regexp)
pattern = "evalregex:#{link_text_or_regexp.inspect}"
else
pattern = link_text_or_regexp.to_s
end
locator = "webratlink=#{pattern}"
selenium.wait_for_element locator, :timeout_in_seconds => 10
selenium.click locator
selenium.get_confirmation if locator =~ /^webratlink=[Dd]elete$/
if selenium.get_attribute("#{locator}@href").include? 'iframe'
selenium.wait_for_frame_to_load("#cboxIframe", 10000)
else
selenium.wait_for_page_to_load
end
end
(also there is a hack in there to handle confirmation boxes when
deleting items)
As you can probably tell, this is a pretty poor way to do this
and is very specific to my app. Perhaps this bug should be raised
against the selenium-client gem? Appologies if this is not a well
described bug.
You can see this in my fork of the Webrat gem:
http://github.com/Rodreegez/webrat/commit/24a477faef251da25afef78ca...
Appologies for the poor code - I'm still very new at this!