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)
|
def area_by_element(element)
|
||||||
return nil if element.nil?
|
return nil if element.nil?
|
||||||
|
@session.elements[Webrat::XML.xpath_to(element)]
|
||||||
expected_path = Webrat::XML.xpath_to(element)
|
|
||||||
|
|
||||||
areas.detect do |possible_area|
|
|
||||||
possible_area.path == expected_path
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_field_with_id(id, *field_types) #:nodoc:
|
def find_field_with_id(id, *field_types) #:nodoc:
|
||||||
|
@ -28,6 +28,8 @@ module Webrat
|
|||||||
def initialize(session, &block) #:nodoc:
|
def initialize(session, &block) #:nodoc:
|
||||||
@session = session
|
@session = session
|
||||||
instance_eval(&block) if block_given?
|
instance_eval(&block) if block_given?
|
||||||
|
|
||||||
|
areas # preload
|
||||||
end
|
end
|
||||||
|
|
||||||
# Verifies an input field or textarea exists on the current page, and stores a value for
|
# 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:
|
def areas #:nodoc:
|
||||||
Webrat::XML.css_search(dom, Area.css_search).map do |element|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ module Webrat
|
|||||||
include Logging
|
include Logging
|
||||||
|
|
||||||
attr_reader :current_url
|
attr_reader :current_url
|
||||||
|
attr_reader :elements
|
||||||
|
|
||||||
def initialize(context = nil) #:nodoc:
|
def initialize(context = nil) #:nodoc:
|
||||||
@http_method = :get
|
@http_method = :get
|
||||||
|
Loading…
Reference in New Issue
Block a user