Sha256: bc3bde606394002b470c4b990c697e0cbdf75c2b1c37b5d0548fa78aca72911c
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module Watir module Locators class Anchor class SelectorBuilder < Element::SelectorBuilder class XPath < Element::SelectorBuilder::XPath end private def build_wd_selector(selector) build_link_text(selector) || build_partial_link_text(selector) || super end def build_link_text(selector) return unless can_convert_to_link_text?(selector) selector.delete(:tag_name) {link_text: selector.delete(:visible_text)} end def can_convert_to_link_text?(selector) selector.keys.sort == %i[tag_name visible_text] && selector[:visible_text].is_a?(String) end def build_partial_link_text(selector) return unless convert_to_partial_link_text?(selector) selector.delete(:tag_name) {partial_link_text: selector.delete(:visible_text).source} end def convert_to_partial_link_text?(selector) regex = selector[:visible_text] selector.keys.sort == %i[tag_name visible_text] && !regex.casefold? && RegexpDisassembler.new(regex).substrings.first == regex.source end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
watir-7.3.0 | lib/watir/locators/anchor/selector_builder.rb |
watir-7.2.2 | lib/watir/locators/anchor/selector_builder.rb |
watir-7.2.1 | lib/watir/locators/anchor/selector_builder.rb |