Methods
public instance
Included modules
- Logging
- SaveAndOpenPage
Attributes
| current_url | [R] | |
| elements | [R] |
Public instance methods
automate
() {|| ...}
[show source]
# File lib/webrat/core/session.rb, line 237 def automate return unless Webrat.configuration.mode == :selenium yield end
basic_auth
(user, pass)
[show source]
# File lib/webrat/core/session.rb, line 93 def basic_auth(user, pass) encoded_login = ["#{user}:#{pass}"].pack("m*") header('HTTP_AUTHORIZATION', "Basic #{encoded_login}") end
check_for_infinite_redirects
()
[show source]
# File lib/webrat/core/session.rb, line 127 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
click_link_within
(selector, link_text)
Works like click_link, but only looks for the link text within a given selector
Example:
click_link_within "#user_12", "Vote"
[show source]
# File lib/webrat/core/session.rb, line 185 def click_link_within(selector, link_text) within(selector) do click_link(link_text) end end
header
(key, value)
[show source]
# File lib/webrat/core/session.rb, line 85 def header(key, value) @custom_headers[key] = value end
http_accept
(mime_type)
[show source]
# File lib/webrat/core/session.rb, line 89 def http_accept(mime_type) header('Accept', Webrat::MIME.mime_type(mime_type)) end
infinite_redirect_limit_exceeded?
()
[show source]
# File lib/webrat/core/session.rb, line 138 def infinite_redirect_limit_exceeded? Webrat.configuration.infinite_redirect_limit && (@_identical_redirect_count || 0) > Webrat.configuration.infinite_redirect_limit end
internal_redirect?
()
[show source]
# File lib/webrat/core/session.rb, line 151 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
redirected_to
()
easy helper to pull out where we were redirected to
[show source]
# File lib/webrat/core/session.rb, line 160 def redirected_to redirect? ? response_location : nil end
reload
()
Reloads the last page requested. Note that this will resubmit forms and their data.
[show source]
# File lib/webrat/core/session.rb, line 174 def reload request_page(@current_url, @http_method, @data) end
simulate
() {|| ...}
[show source]
# File lib/webrat/core/session.rb, line 232 def simulate return if Webrat.configuration.mode == :selenium yield end
visit
(url = nil, http_method = :get, data = {})
Issues a GET request for a page, follows any redirects, and verifies the final page load was successful.
Example:
visit "/"
[show source]
# File lib/webrat/core/session.rb, line 205 def visit(url = nil, http_method = :get, data = {}) request_page(url, http_method, data) end
within
(selector) {|current_scope| ...}
[show source]
# File lib/webrat/core/session.rb, line 193 def within(selector) scopes.push(Scope.from_scope(self, current_scope, selector)) ret = yield(current_scope) scopes.pop return ret end
xml_content_type?
()
[show source]
# File lib/webrat/core/session.rb, line 228 def xml_content_type? false end