Module: Webrat::Locators
- Included in:
- Scope
- Defined in:
- lib/webrat/core/locators.rb,
lib/webrat/core/locators/locator.rb,
lib/webrat/core/locators/area_locator.rb,
lib/webrat/core/locators/form_locator.rb,
lib/webrat/core/locators/link_locator.rb,
lib/webrat/core/locators/field_locator.rb,
lib/webrat/core/locators/label_locator.rb,
lib/webrat/core/locators/button_locator.rb,
lib/webrat/core/locators/field_by_id_locator.rb,
lib/webrat/core/locators/field_named_locator.rb,
lib/webrat/core/locators/field_labeled_locator.rb,
lib/webrat/core/locators/select_option_locator.rb
Defined Under Namespace
Classes: AreaLocator, ButtonLocator, FieldByIdLocator, FieldLabeledLocator, FieldLocator, FieldNamedLocator, FormLocator, LabelLocator, LinkLocator, Locator, SelectOptionLocator
Instance Method Summary collapse
-
#field(*args) ⇒ Object
:nodoc:.
- #field_by_xpath(xpath) ⇒ Object
-
#field_labeled(label, *field_types) ⇒ Object
Locates a form field based on a
label
element in the HTML source. - #field_named(name, *field_types) ⇒ Object
- #field_with_id(id, *field_types) ⇒ Object
-
#find_area(id_or_title) ⇒ Object
:nodoc:.
-
#find_button(value) ⇒ Object
:nodoc:.
-
#find_link(text_or_title_or_id) ⇒ Object
:nodoc:.
-
#select_option(option_text, id_or_name_or_label = nil) ⇒ Object
:nodoc:.
Instance Method Details
#field(*args) ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/webrat/core/locators/field_locator.rb', line 20 def field(*args) # :nodoc: FieldLocator.new(@session, dom, *args).locate! end |
#field_by_xpath(xpath) ⇒ Object
15 16 17 |
# File 'lib/webrat/core/locators.rb', line 15 def field_by_xpath(xpath) Field.load(@session, Webrat::XML.xpath_at(dom, xpath)) end |
#field_labeled(label, *field_types) ⇒ Object
Locates a form field based on a label
element in the HTML source. This can be useful in order to verify that a field is pre-filled with the correct value.
Example:
field_labeled("First name").value.should == "Bryan"
51 52 53 |
# File 'lib/webrat/core/locators/field_labeled_locator.rb', line 51 def field_labeled(label, *field_types) FieldLabeledLocator.new(@session, dom, label, *field_types).locate! end |
#field_named(name, *field_types) ⇒ Object
36 37 38 |
# File 'lib/webrat/core/locators/field_named_locator.rb', line 36 def field_named(name, *field_types) FieldNamedLocator.new(@session, dom, name, *field_types).locate! end |
#field_with_id(id, *field_types) ⇒ Object
32 33 34 |
# File 'lib/webrat/core/locators/field_by_id_locator.rb', line 32 def field_with_id(id, *field_types) FieldByIdLocator.new(@session, dom, id, *field_types).locate! end |
#find_area(id_or_title) ⇒ Object
:nodoc:
33 34 35 |
# File 'lib/webrat/core/locators/area_locator.rb', line 33 def find_area(id_or_title) #:nodoc: AreaLocator.new(@session, dom, id_or_title).locate! end |
#find_button(value) ⇒ Object
:nodoc:
49 50 51 |
# File 'lib/webrat/core/locators/button_locator.rb', line 49 def (value) #:nodoc: ButtonLocator.new(@session, dom, value).locate! end |
#find_link(text_or_title_or_id) ⇒ Object
:nodoc:
70 71 72 |
# File 'lib/webrat/core/locators/link_locator.rb', line 70 def find_link(text_or_title_or_id) #:nodoc: LinkLocator.new(@session, dom, text_or_title_or_id).locate! end |
#select_option(option_text, id_or_name_or_label = nil) ⇒ Object
:nodoc:
54 55 56 |
# File 'lib/webrat/core/locators/select_option_locator.rb', line 54 def select_option(option_text, id_or_name_or_label = nil) #:nodoc: SelectOptionLocator.new(@session, dom, option_text, id_or_name_or_label).locate! end |