Use Nokigiri #search instead of /
This commit is contained in:
parent
e5b0e77332
commit
0cb64f6483
@ -311,8 +311,8 @@ module Webrat
|
|||||||
protected
|
protected
|
||||||
|
|
||||||
def default_value
|
def default_value
|
||||||
selected_options = @element / ".//option[@selected='selected']"
|
selected_options = @element.search(".//option[@selected='selected']")
|
||||||
selected_options = @element / ".//option[position() = 1]" if selected_options.empty?
|
selected_options = @element.search(".//option[position() = 1]") if selected_options.empty?
|
||||||
|
|
||||||
selected_options.map do |option|
|
selected_options.map do |option|
|
||||||
return "" if option.nil?
|
return "" if option.nil?
|
||||||
@ -325,7 +325,7 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def option_elements
|
def option_elements
|
||||||
(@element / ".//option")
|
@element.search(".//option")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require "webrat/core_extensions/meta_class"
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
|
|
||||||
def self.nokogiri_document(stringlike)
|
def self.nokogiri_document(stringlike)
|
||||||
@ -14,6 +16,12 @@ module Webrat
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.define_dom_method(object, dom)
|
||||||
|
object.meta_class.send(:define_method, :dom) do
|
||||||
|
dom
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
require "nokogiri"
|
require "nokogiri"
|
||||||
require "webrat/core/form"
|
require "webrat/core/form"
|
||||||
require "webrat/core/locators"
|
require "webrat/core/locators"
|
||||||
require "webrat/core_extensions/meta_class"
|
|
||||||
|
|
||||||
module Webrat
|
module Webrat
|
||||||
class Scope
|
class Scope
|
||||||
@ -168,13 +167,8 @@ module Webrat
|
|||||||
|
|
||||||
def page_dom
|
def page_dom
|
||||||
return @response.dom if @response.respond_to?(:dom)
|
return @response.dom if @response.respond_to?(:dom)
|
||||||
|
|
||||||
dom = Webrat.nokogiri_document(@response_body)
|
dom = Webrat.nokogiri_document(@response_body)
|
||||||
|
Webrat.define_dom_method(@response, dom)
|
||||||
@response.meta_class.send(:define_method, :dom) do
|
|
||||||
dom
|
|
||||||
end
|
|
||||||
|
|
||||||
return dom
|
return dom
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -191,13 +185,13 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def areas
|
def areas
|
||||||
(dom / "area").map do |element|
|
dom.search("area").map do |element|
|
||||||
Area.new(@session, element)
|
Area.new(@session, element)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def links
|
def links
|
||||||
(dom / "a[@href]").map do |link_element|
|
dom.search("a[@href]").map do |link_element|
|
||||||
Link.new(@session, link_element)
|
Link.new(@session, link_element)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -205,7 +199,7 @@ module Webrat
|
|||||||
def forms
|
def forms
|
||||||
return @forms if @forms
|
return @forms if @forms
|
||||||
|
|
||||||
@forms = (dom / "form").map do |form_element|
|
@forms = dom.search("form").map do |form_element|
|
||||||
Form.new(@session, form_element)
|
Form.new(@session, form_element)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user