#301 new
Rodreegez

selenium wait_for_frame_to_load

Reported by Rodreegez | October 15th, 2009 @ 10:21 AM

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!

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby Acceptance Testing for Web applications.

Shared Ticket Bins

People watching this ticket

Tags

Pages