Store references to Areas in a Session#elements hash
This commit is contained in:
parent
857625840f
commit
154c83eced
@ -54,12 +54,7 @@ module Webrat
|
||||
|
||||
def area_by_element(element)
|
||||
return nil if element.nil?
|
||||
|
||||
expected_path = Webrat::XML.xpath_to(element)
|
||||
|
||||
areas.detect do |possible_area|
|
||||
possible_area.path == expected_path
|
||||
end
|
||||
@session.elements[Webrat::XML.xpath_to(element)]
|
||||
end
|
||||
|
||||
def find_field_with_id(id, *field_types) #:nodoc:
|
||||
|
@ -28,6 +28,8 @@ module Webrat
|
||||
def initialize(session, &block) #:nodoc:
|
||||
@session = session
|
||||
instance_eval(&block) if block_given?
|
||||
|
||||
areas # preload
|
||||
end
|
||||
|
||||
# Verifies an input field or textarea exists on the current page, and stores a value for
|
||||
@ -307,7 +309,9 @@ module Webrat
|
||||
|
||||
def areas #:nodoc:
|
||||
Webrat::XML.css_search(dom, Area.css_search).map do |element|
|
||||
Area.new(@session, element)
|
||||
area = Area.new(@session, element)
|
||||
@session.elements[Webrat::XML.xpath_to(element)] = area
|
||||
area
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -32,6 +32,7 @@ module Webrat
|
||||
include Logging
|
||||
|
||||
attr_reader :current_url
|
||||
attr_reader :elements
|
||||
|
||||
def initialize(context = nil) #:nodoc:
|
||||
@http_method = :get
|
||||
|
Loading…
Reference in New Issue
Block a user