Class: Watir::Locators::Element::SelectorBuilder
- Inherits:
-
Object
- Object
- Watir::Locators::Element::SelectorBuilder
- Includes:
- Exception
- Defined in:
- lib/watir/locators/element/selector_builder.rb,
lib/watir/locators/element/selector_builder/xpath.rb,
lib/watir/locators/element/selector_builder/xpath_support.rb,
lib/watir/locators/element/selector_builder/regexp_disassembler.rb
Direct Known Subclasses
Anchor::SelectorBuilder, Button::SelectorBuilder, Cell::SelectorBuilder, Row::SelectorBuilder, TextArea::SelectorBuilder, TextField::SelectorBuilder
Defined Under Namespace
Modules: XpathSupport Classes: RegexpDisassembler, XPath
Constant Summary collapse
- WILDCARD_ATTRIBUTE =
/^(aria|data)_(.+)$/.freeze
- VALID_WHATS =
Hash.new([String, Regexp, TrueClass, FalseClass]).merge(adjacent: [::Symbol], xpath: [String], css: [String], index: [Integer], visible: [TrueClass, FalseClass], tag_name: [String, Regexp, ::Symbol], visible_text: [String, Regexp], scope: [Hash], text: [String, Regexp]).freeze
Instance Attribute Summary collapse
-
#built ⇒ Object
readonly
Returns the value of attribute built.
-
#custom_attributes ⇒ Object
readonly
Returns the value of attribute custom_attributes.
Instance Method Summary collapse
- #build(selector) ⇒ Object
-
#initialize(valid_attributes, query_scope) ⇒ SelectorBuilder
constructor
A new instance of SelectorBuilder.
- #wd_locators ⇒ Object
Constructor Details
#initialize(valid_attributes, query_scope) ⇒ SelectorBuilder
Returns a new instance of SelectorBuilder.
19 20 21 22 23 |
# File 'lib/watir/locators/element/selector_builder.rb', line 19 def initialize(valid_attributes, query_scope) @valid_attributes = valid_attributes @custom_attributes = [] @query_scope = query_scope end |
Instance Attribute Details
#built ⇒ Object (readonly)
Returns the value of attribute built
6 7 8 |
# File 'lib/watir/locators/element/selector_builder.rb', line 6 def built @built end |
#custom_attributes ⇒ Object (readonly)
Returns the value of attribute custom_attributes
6 7 8 |
# File 'lib/watir/locators/element/selector_builder.rb', line 6 def custom_attributes @custom_attributes end |
Instance Method Details
#build(selector) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/watir/locators/element/selector_builder.rb', line 25 def build(selector) @selector = selector deprecated_locators normalize_selector inspected = selector.inspect scope = @query_scope unless @selector.key?(:scope) || @query_scope.is_a?(Watir::Browser) @built = wd_locators.empty? ? build_wd_selector(@selector) : @selector @built.delete(:index) if @built[:index]&.zero? @built[:scope] = scope if scope Watir.logger.info "Converted #{inspected} to #{@built.inspect}" @built end |
#wd_locators ⇒ Object
41 42 43 |
# File 'lib/watir/locators/element/selector_builder.rb', line 41 def wd_locators Watir::Locators::W3C_FINDERS & @selector.keys end |