Sha256: af4efc4b129dccdf6b06d319a830a3ce52814af6aa74cfbb7fc4a2a66010910a
Contents?: true
Size: 881 Bytes
Versions: 7
Compression:
Stored size: 881 Bytes
Contents
# frozen_string_literal: true # Module to help form xpaths for generic identification module Xpath class << self # @return [String] Translate string to uppercase letters def upcase(xpath_method) "translate(#{xpath_method},'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" end # @return [String] Xpath to retrieve input beside a label def input_by_label(label) upcase_text = upcase('text()') "//input[@id=(//label[contains(#{upcase_text},'#{label.upcase}')]/@for)]" end # @return [String] Xpath to retrieve input either by a label or a attribute matching it def label_or_attribute(field_name) any_input_with_atr = "//input[@*='#{field_name}']" input_with_text = "//input[text()='#{field_name}']" [input_by_label(field_name), any_input_with_atr, input_with_text] .join('|') end end end
Version data entries
7 entries across 7 versions & 1 rubygems