Class: Watir::Form

Inherits:
Element show all
Defined in:
lib/watir-classic/form.rb

Constant Summary

Constants inherited from Element

Element::TO_S_SIZE

Instance Attribute Summary

Attributes inherited from Element

#container

Attributes included from Container

#activeObjectHighLightColor, #page_container, #type_keys, #typingspeed

Instance Method Summary collapse

Methods inherited from Element

#<=>, #activeObjectHighLightColor, #assert_enabled, #assert_exists, #attribute_value, #click, #click!, #create_event, #disabled?, #dispatch_event, #document, #double_click, #enabled?, #exists?, #fire_event, #focus, #focused?, #inspect, #method_missing, #ole_object, #ole_object=, #parent, #right_click, #send_keys, #style, #tag_name, #text, #to_s, #to_subtype, #type_keys, #typingspeed, #visible?

Methods included from DragAndDropHelper

#drag_and_drop_by, #drag_and_drop_on

Methods included from Container

#alert, #locator_for, #modal_dialog, #set_container, support_element, #wait

Methods included from Exception

message_for_unable_to_locate

Methods included from ElementExtensions

#present?, #wait_until_present, #wait_while_present, #when_present

Constructor Details

#initialize(container, specifiers) ⇒ Form

Returns a new instance of Form.



4
5
6
7
# File 'lib/watir-classic/form.rb', line 4

def initialize(container, specifiers)
  super
  copy_test_config container
end

Dynamic Method Handling

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

Instance Method Details

#__ole_inner_elementsObject



41
42
43
44
# File 'lib/watir-classic/form.rb', line 41

def __ole_inner_elements
  assert_exists
  @o.elements
end

#flash(number = 10) ⇒ Object

causes the object to flash. Normally used in IRB when creating scripts Default is 10



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/watir-classic/form.rb', line 75

def flash number=10
  assert_exists
  @original_styles = {}
  number.times do
    count = 0
    @o.elements.each do |element|
      highlight(:set, element, count)
      count += 1
    end
    sleep 0.05
    count = 0
    @o.elements.each do |element|
      highlight(:clear, element, count)
      count += 1
    end
    sleep 0.05
  end
end

#form_methodObject



17
18
19
20
# File 'lib/watir-classic/form.rb', line 17

def form_method
  assert_exists
  ole_object.invoke('method')
end

#locateObject



30
31
32
# File 'lib/watir-classic/form.rb', line 30

def locate
  @o = @container.locator_for(FormLocator, @specifiers, self.class).locate
end

#method(arg = nil) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/watir-classic/form.rb', line 22

def method(arg = nil)
  if arg.nil?
    form_method
  else
    super
  end
end

#nameObject



11
12
13
14
15
# File 'lib/watir-classic/form.rb', line 11

def name
  assert_exists
  name = ole_object.getAttributeNode('name')
  name ? name.value : ''
end

#submitObject

Submit the data – equivalent to pressing Enter or Return to submit a form.



35
36
37
38
39
# File 'lib/watir-classic/form.rb', line 35

def submit 
  assert_exists
  @o.submit(0) if dispatch_event "onSubmit"
  @container.wait
end