Class: Watir::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/tagen/watir.rb

Instance Method Summary collapse

Instance Method Details

#set2(selector, value = nil) ⇒ Object

quick set value.

Examples:


form = browser.form(id: "foo")
form.set("//input[@name='value']", "hello")
form.set("//input[@name='check']", true)
form.set("//select[@name='foo']", "Bar")
form.set("//textarea[@name='foo']", "bar")


94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/tagen/watir.rb', line 94

def set2(selector, value=nil)
  elem = element(xpath: selector).to_subtype

  case elem
  when Watir::Radio
    elem.set
  when Watir::Select
    elem.select value
  when Watir::Input
    elem.set value
  when Watir::TextArea
    elem.set value
  else
    elem.click
  end
end