module Xpath
Module to help form xpaths for generic identification
Public Class Methods
input_by_label(label)
click to toggle source
@return [String] Xpath
to retrieve input beside a label
# File lib/generic_test/xpath.rb, line 12 def input_by_label(label) upcase_text = upcase('text()') "//input[@id=(//label[contains(#{upcase_text},'#{label.upcase}')]/@for)]" end
label_or_attribute(field_name)
click to toggle source
@return [String] Xpath
to retrieve input either by a label or a attribute matching it
# File lib/generic_test/xpath.rb, line 18 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
upcase(xpath_method)
click to toggle source
@return [String] Translate string to uppercase letters
# File lib/generic_test/xpath.rb, line 7 def upcase(xpath_method) "translate(#{xpath_method},'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')" end