Class: Locator::Element
- Inherits:
-
Object
- Object
- Locator::Element
- Defined in:
- lib/locator/element.rb,
lib/locator/element/area.rb,
lib/locator/element/file.rb,
lib/locator/element/form.rb,
lib/locator/element/link.rb,
lib/locator/element/field.rb,
lib/locator/element/input.rb,
lib/locator/element/label.rb,
lib/locator/element/button.rb,
lib/locator/element/select.rb,
lib/locator/element/check_box.rb,
lib/locator/element/text_area.rb,
lib/locator/element/form_element.rb,
lib/locator/element/hidden_field.rb,
lib/locator/element/radio_button.rb,
lib/locator/element/elements_list.rb,
lib/locator/element/select_option.rb,
lib/locator/element/labeled_element.rb
Direct Known Subclasses
Area, ElementsList, Form, FormElement, Label, LabeledElement, Link, SelectOption
Defined Under Namespace
Classes: Area, Button, CheckBox, ElementsList, Field, File, Form, FormElement, HiddenField, Input, Label, LabeledElement, Link, RadioButton, Select, SelectOption, TextArea
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#locatables ⇒ Object
readonly
Returns the value of attribute locatables.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #all(dom, *args) ⇒ Object
-
#initialize(name = nil, locatables = nil, attributes = nil) ⇒ Element
constructor
A new instance of Element.
- #locate(*args) ⇒ Object
- #xpath(attributes = {}) ⇒ Object
Constructor Details
#initialize(name = nil, locatables = nil, attributes = nil) ⇒ Element
Returns a new instance of Element.
23 24 25 26 27 |
# File 'lib/locator/element.rb', line 23 def initialize(name = nil, locatables = nil, attributes = nil) @name = name || '*' @locatables = { :equals => :id, :matches => :content }.merge(locatables || {}) @attributes = attributes || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
21 22 23 |
# File 'lib/locator/element.rb', line 21 def attributes @attributes end |
#locatables ⇒ Object (readonly)
Returns the value of attribute locatables.
21 22 23 |
# File 'lib/locator/element.rb', line 21 def locatables @locatables end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/locator/element.rb', line 21 def name @name end |
Instance Method Details
#all(dom, *args) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/locator/element.rb', line 33 def all(dom, *args) attributes, selector = args.last.is_a?(Hash) ? args.pop : {}, args.pop result = lookup(dom, selector, attributes) result.sort! if selector result end |
#locate(*args) ⇒ Object
29 30 31 |
# File 'lib/locator/element.rb', line 29 def locate(*args) all(*args).first end |