# File lib/webrat/core/session.rb, line 248 def automate return unless Webrat.configuration.mode == :selenium yield end
# File lib/webrat/core/session.rb, line 104 def basic_auth(user, pass) encoded_login = ["#{user}:#{pass}"].pack("m*").gsub(/\n/, '') header('HTTP_AUTHORIZATION', "Basic #{encoded_login}") end
# File lib/webrat/core/session.rb, line 138 def check_for_infinite_redirects if current_url == response_location @_identical_redirect_count ||= 0 @_identical_redirect_count += 1 end if infinite_redirect_limit_exceeded? raise InfiniteRedirectError.new("#{Webrat.configuration.infinite_redirect_limit} redirects to the same URL (#{current_url.inspect})") end end
Works like click_link, but only looks for the link text within a given selector
Example:
click_link_within "#user_12", "Vote"
# File lib/webrat/core/session.rb, line 196 def click_link_within(selector, link_text) within(selector) do click_link(link_text) end end
# File lib/webrat/core/session.rb, line 96 def header(key, value) @custom_headers[key] = value end
# File lib/webrat/core/session.rb, line 100 def http_accept(mime_type) header('Accept', Webrat::MIME.mime_type(mime_type)) end
# File lib/webrat/core/session.rb, line 149 def infinite_redirect_limit_exceeded? Webrat.configuration.infinite_redirect_limit && (@_identical_redirect_count || 0) > Webrat.configuration.infinite_redirect_limit end
# File lib/webrat/core/session.rb, line 162 def internal_redirect? return false unless redirect? #should keep internal_redirects if the subdomain changes current_host_domain = current_host.split('.')[-2..-1].join('.') rescue current_host response_location_host_domain = response_location_host.split('.')[-2..-1].join('.') rescue response_location_host current_host_domain == response_location_host_domain end
easy helper to pull out where we were redirected to
# File lib/webrat/core/session.rb, line 171 def redirected_to redirect? ? response_location : nil end
Reloads the last page requested. Note that this will resubmit forms and their data.
# File lib/webrat/core/session.rb, line 185 def reload request_page(@current_url, @http_method, @data) end
# File lib/webrat/core/session.rb, line 243 def simulate return if Webrat.configuration.mode == :selenium yield end
Issues a GET request for a page, follows any redirects, and verifies the final page load was successful.
Example:
visit "/"
# File lib/webrat/core/session.rb, line 216 def visit(url = nil, http_method = :get, data = {}) request_page(url, http_method, data) end
Generated with the Darkfish Rdoc Generator 2.