Sha256: 71a8ac8e6d07a34880dc2e24b9e61ab4350b80ce48dbe89d5601eb7e29b4672d

Contents?: true

Size: 555 Bytes

Versions: 17

Compression:

Stored size: 555 Bytes

Contents

module Locator::Equal

  EQUAL_REGEX = /\A([^\p{L}]*)(=)(.*)\Z/

  module_function

  def execute(locator)
    matches = EQUAL_REGEX.match(locator)

    if matches
      captures = matches.captures
      locator = "#{captures[0]}#{captures[2]}"
      xpath = ".//*[text()='#{locator}']"

      [locator, xpath]
    else
      #
      # find node that contains *text* and does not have any child nodes that contain *text*
      #
      xpath = ".//*[contains(., '#{locator}')][not(*[contains(., '#{locator}')])]"

      [locator, xpath]
    end
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pickles-0.2.4 lib/cucumber/pickles/locator/equal.rb
pickles-0.2.3 lib/cucumber/pickles/locator/equal.rb
pickles-0.2.2 lib/cucumber/pickles/locator/equal.rb
pickles-0.2.1 lib/cucumber/pickles/locator/equal.rb
pickles-0.2.0 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.12 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.10 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.9 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.8 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.7 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.6 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.5 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.4 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.3 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.2 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.1 lib/cucumber/pickles/locator/equal.rb
pickles-0.1.0 lib/cucumber/pickles/locator/equal.rb