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/content.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, Content, ElementsList, Form, FormElement, Label, LabeledElement, Link, SelectOption
Defined Under Namespace
Classes: Area, Button, CheckBox, Content, 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.
-
#css ⇒ Object
readonly
Returns the value of attribute css.
-
#locatables ⇒ Object
readonly
Returns the value of attribute locatables.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #all(scope, *args) ⇒ Object
-
#initialize(*args) ⇒ Element
constructor
A new instance of Element.
- #locate(*args) ⇒ Object
- #xpath(*args) ⇒ Object
Constructor Details
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
25 26 27 |
# File 'lib/locator/element.rb', line 25 def attributes @attributes end |
#css ⇒ Object (readonly)
Returns the value of attribute css.
25 26 27 |
# File 'lib/locator/element.rb', line 25 def css @css end |
#locatables ⇒ Object (readonly)
Returns the value of attribute locatables.
25 26 27 |
# File 'lib/locator/element.rb', line 25 def locatables @locatables end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
25 26 27 |
# File 'lib/locator/element.rb', line 25 def name @name end |
Instance Method Details
#all(scope, *args) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/locator/element.rb', line 36 def all(scope, *args) attributes, selector = args.last.is_a?(Hash) ? args.pop : {}, args.pop result = lookup(scope, selector, attributes) result.sort! if selector result end |
#locate(*args) ⇒ Object
32 33 34 |
# File 'lib/locator/element.rb', line 32 def locate(*args) all(*args).first # || raise(ElementNotFound.new(*args)) end |
#xpath(*args) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/locator/element.rb', line 43 def xpath(*args) = args.last.is_a?(Hash) ? args.pop : {} attributes = self.attributes.merge(.except(:xpath, :css)) # TODO move to Xpath? xpath, css = .values_at(:xpath, :css) xpath ||= css ? ::Nokogiri::CSS.xpath_for(*css).first : args.pop Xpath.new(xpath || name || '*', attributes).to_s end |