Class: FireWatir::Form

Inherits:
Element show all
Defined in:
lib/firewatir/elements/form.rb

Constant Summary

Constants inherited from Element

Element::FIRST_ORDERED_NODE_TYPE, Element::NUMBER_TYPE, Element::ORDERED_NODE_ITERATOR_TYPE, Element::TO_S_SIZE

Constants included from Container

Container::DEFAULT_HIGHLIGHT_COLOR, Container::MACHINE_IP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Element

#assert_enabled, #assert_exists, #attribute_value, #click, #contains_text, #disabled, #document_var, #element_by_xpath, #element_type, #elements_by_xpath, #enabled?, #exists?, #fire_event, #inspect, #method_missing, #text, #to_s, #visible?, #wait

Methods included from Container

#button, #cell, #checkbox, #dd, #dl, #dt, #file_field, #form, #frame, #hidden, #image, #link, #radio, #row, #select_list, #show_all_objects, #table, #text_field

Methods included from JsshSocket

#js_eval, #js_eval_method, #jssh_socket, #read_socket

Constructor Details

#initialize(container, how, what) ⇒ Form

Description:

Initializes the instance of form object.

Input:

- how - Attribute to identify the form element.
- what - Value of that attribute.


13
14
15
16
17
# File 'lib/firewatir/elements/form.rb', line 13

def initialize(container, how, what)
  @how = how
  @what = what
  @container = container
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class FireWatir::Element

Instance Attribute Details

#element_nameObject

Returns the value of attribute element_name.



4
5
6
# File 'lib/firewatir/elements/form.rb', line 4

def element_name
  @element_name
end

Instance Method Details

#locateObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/firewatir/elements/form.rb', line 19

def locate
  # Get form using xpath.
  case @how
  when :jssh_name
    @element_name = @what
  when :xpath
    @element_name = element_by_xpath(@container, @what)
  else
    @element_name = locate_tagged_element("form", @how, @what)
  end
  @o = self
end

#submitObject

Submit the form. Equivalent to pressing Enter or Return to submit a form.



33
34
35
36
37
# File 'lib/firewatir/elements/form.rb', line 33

def submit
  assert_exists
  submit_form
  @o.wait
end