Sha256: cdcf0255eb0f40247c02a34bf64a6e8ec2ebc4978ef1967ed8a4fead809031d6
Contents?: true
Size: 1.12 KB
Versions: 19
Compression:
Stored size: 1.12 KB
Contents
module Watir module Locators class Anchor class SelectorBuilder < Element::SelectorBuilder 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
19 entries across 19 versions & 1 rubygems