Method: XPath::HTML#select

Defined in:
lib/xpath/html.rb

#select(locator, options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/xpath/html.rb', line 48

def select(locator, options={})
  xpath = locate_field(descendant(:select), locator)

  options[:options].each do |option|
    xpath = xpath[descendant(:option).text.equals(option)]
  end if options[:options]

  [options[:selected]].flatten.each do |option|
    xpath = xpath[descendant(:option)[attr(:selected)].text.equals(option)]
  end if options[:selected]

  xpath
end