Class: Selenium::WebDriver::Elements::Form

Inherits:
Element
  • Object
show all
Defined in:
lib/selenium/webdriver/elements/form.rb

Instance Method Summary collapse

Methods inherited from Element

#create_element, #element_present?, #find_element, #find_elements, #method_missing

Constructor Details

#initialize(element, browser) ⇒ Form

Returns a new instance of Form.



9
10
11
12
13
14
# File 'lib/selenium/webdriver/elements/form.rb', line 9

def initialize element, browser
  super element, browser
  unless element.tag_name == 'form'
    raise TypeError.new "Can't create Form decorator for #{element.inspect}"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Selenium::WebDriver::Elements::Element

Instance Method Details

#populate(data) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/selenium/webdriver/elements/form.rb', line 16

def populate data
  inputs = []
  find_elements(:tag_name => 'input').each do |input|
    inputs << input if input.is_a? Textbox or input.is_a? Checkbox or input.is_a? FileChooser
  end
  inputs += find_elements :tag_name => 'textarea'
  inputs += find_elements :tag_name => 'select'

  inputs.each do |input|
    input.populate data[input['name']]
  end
  self
end