Method: XPath::HTML#field

Defined in:
lib/xpath/html.rb

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



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/xpath/html.rb', line 29

def field(locator, options={})
  if options[:with]
    fillable_field(locator, options)
  else
    xpath = descendant(:input, :textarea, :select)[~attr(:type).one_of('submit', 'image', 'hidden')]
    xpath = locate_field(xpath, locator)
    xpath = xpath[attr(:checked)] if options[:checked]
    xpath = xpath[~attr(:checked)] if options[:unchecked]
    xpath
  end
end