Namespace locators in Webrat::Locators

This commit is contained in:
Bryan Helmkamp 2008-11-29 02:00:57 -05:00
parent d7eec20950
commit a472bbfbde
6 changed files with 169 additions and 133 deletions

View File

@ -1,6 +1,9 @@
require "webrat/core/locators/locator" require "webrat/core/locators/locator"
class AreaLocator < Locator module Webrat
module Locators
class AreaLocator < Locator
def locate def locate
@scope.area_by_element(area_element) @scope.area_by_element(area_element)
@ -21,4 +24,7 @@ class AreaLocator < Locator
Webrat::XML.css_search(@scope.dom, "area") Webrat::XML.css_search(@scope.dom, "area")
end end
end
end
end end

View File

@ -1,6 +1,9 @@
require "webrat/core/locators/locator" require "webrat/core/locators/locator"
class ButtonLocator < Locator module Webrat
module Locators
class ButtonLocator < Locator
def locate def locate
@scope.field_by_element(button_element) @scope.field_by_element(button_element)
@ -34,7 +37,10 @@ class ButtonLocator < Locator
end end
def button_elements def button_elements
Webrat::XML.xpath_search(@scope.dom, *Webrat::ButtonField.xpath_search) Webrat::XML.xpath_search(@scope.dom, *ButtonField.xpath_search)
end end
end
end
end end

View File

@ -1,6 +1,9 @@
require "webrat/core/locators/locator" require "webrat/core/locators/locator"
class FieldByIdLocator < Locator module Webrat
module Locators
class FieldByIdLocator < Locator
def locate def locate
@scope.field_by_element(field_element) @scope.field_by_element(field_element)
@ -17,7 +20,10 @@ class FieldByIdLocator < Locator
end end
def field_elements def field_elements
Webrat::XML.xpath_search(@scope.dom, *Webrat::Field.xpath_search) Webrat::XML.xpath_search(@scope.dom, *Field.xpath_search)
end end
end
end
end end

View File

@ -1,6 +1,9 @@
require "webrat/core/locators/locator" require "webrat/core/locators/locator"
class FieldNamedLocator < Locator module Webrat
module Locators
class FieldNamedLocator < Locator
def locate def locate
@scope.field_by_element(field_element) @scope.field_by_element(field_element)
@ -24,4 +27,7 @@ class FieldNamedLocator < Locator
end end
end end
end
end
end end

View File

@ -1,6 +1,9 @@
require "webrat/core/locators/locator" require "webrat/core/locators/locator"
class LinkLocator < Locator module Webrat
module Locators
class LinkLocator < Locator
def locate def locate
@scope.link_by_element(link_element) @scope.link_by_element(link_element)
@ -38,7 +41,7 @@ class LinkLocator < Locator
end end
def link_elements def link_elements
Webrat::XML.css_search(@scope.dom, *Webrat::Link.css_search) Webrat::XML.css_search(@scope.dom, *Link.css_search)
end end
def replace_nbsp(str) def replace_nbsp(str)
@ -49,4 +52,7 @@ class LinkLocator < Locator
str.gsub('&#xA0;',' ').gsub('&nbsp;', ' ') str.gsub('&#xA0;',' ').gsub('&nbsp;', ' ')
end end
end
end
end end

View File

@ -1,4 +1,7 @@
class Locator module Webrat
module Locators
class Locator
def initialize(scope, value, *field_types) def initialize(scope, value, *field_types)
@scope = scope @scope = scope
@ -6,4 +9,7 @@ class Locator
@field_types = field_types @field_types = field_types
end end
end
end
end end