Class: Watir::Form
- Includes:
- Container, FormAccess
- Defined in:
- lib/watir/form.rb,
lib/watir/camel_case.rb
Overview
Form Factory object
Constant Summary
Constants inherited from Element
Instance Attribute Summary collapse
-
#form ⇒ Object
Returns the value of attribute form.
-
#ole_object ⇒ Object
Returns the value of attribute ole_object.
Attributes included from Container
#activeObjectHighLightColor, #page_container, #type_keys, #typingspeed
Attributes inherited from Element
Instance Method Summary collapse
- #assert_exists ⇒ Object
- #document ⇒ Object
- #exists? ⇒ Boolean (also: #exist?)
-
#flash(number = 10) ⇒ Object
causes the object to flash.
-
#initialize(container, how, what) ⇒ Form
constructor
-
container - the containing object, normally an instance of IE * how - symbol - how we access the form (:name, :id, :index, :action, :method) * what - what we use to access the form.
-
-
#submit ⇒ Object
Submit the data – equivalent to pressing Enter or Return to submit a form.
- #wait(no_sleep = false) ⇒ Object (also: #waitForIE)
Methods included from Container
#area, #areas, #button, #buttons, #cell, #cells, #checkbox, #checkboxes, #dds, #divs, #dls, #dts, #element, #element_by_css, #elements, #ems, #file_field, #file_fields, #forms, #frame, #hidden, #hiddens, #image, #images, #labels, #link, #links, #lis, #locate_all_elements, #locate_input_element, #locate_tagged_element, #log, #map, #maps, #modal_dialog, #popup, #pres, #ps, #radio, #radios, #row, #rows, #select_list, #select_lists, #set_container, #show_all_objects, #spans, #strongs, #table, #tables, #text_field, #text_fields
Methods included from FormAccess
Methods inherited from Element
#<=>, #activeObjectHighLightColor, #after_text, #assert_enabled, #attribute_value, #before_text, #click, #click!, #click_no_wait, #enabled?, #fire_event, #focus, #inspect, #parent, #text, #to_s, #type_keys, #typingspeed, #visible?
Constructor Details
#initialize(container, how, what) ⇒ Form
-
container - the containing object, normally an instance of IE
-
how - symbol - how we access the form (:name, :id, :index, :action, :method)
-
what - what we use to access the form
-
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/watir/form.rb', line 38 def initialize(container, how, what) set_container container @how = how @what = what log "Get form how is #{@how} what is #{@what} " # Get form using xpath. if @how == :xpath @ole_object = @container.element_by_xpath(@what) elsif @how == :css @ole_object = @container.element_by_css(@what) else count = 1 doc = @container.document doc.forms.each do |thisForm| next unless @ole_object == nil wrapped = FormWrapper.new(thisForm) @ole_object = case @how when :name, :id, :method, :action @what.matches(wrapped.send(@how)) ? thisForm : nil when :index count == @what ? thisForm : nil else raise MissingWayOfFindingObjectException, "#{how} is an unknown way of finding a form (#{what})" end count += 1 end end super(@ole_object) copy_test_config container end |
Instance Attribute Details
#form ⇒ Object
Returns the value of attribute form.
33 34 35 |
# File 'lib/watir/form.rb', line 33 def form @form end |
#ole_object ⇒ Object
Returns the value of attribute ole_object.
33 34 35 |
# File 'lib/watir/form.rb', line 33 def ole_object @ole_object end |
Instance Method Details
#assert_exists ⇒ Object
79 80 81 82 83 84 |
# File 'lib/watir/form.rb', line 79 def assert_exists unless exists? raise UnknownFormException, "Unable to locate a form using #{@how} and #{@what}" end end |
#document ⇒ Object
99 100 101 |
# File 'lib/watir/form.rb', line 99 def document return @ole_object end |
#exists? ⇒ Boolean Also known as: exist?
74 75 76 |
# File 'lib/watir/form.rb', line 74 def exists? @ole_object ? true : false end |
#flash(number = 10) ⇒ Object
causes the object to flash. Normally used in IRB when creating scripts Default is 10
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/watir/form.rb', line 137 def flash number=10 @original_styles = {} number.times do count = 0 @ole_object.elements.each do |element| highlight(:set, element, count) count += 1 end sleep 0.05 count = 0 @ole_object.elements.each do |element| highlight(:clear, element, count) count += 1 end sleep 0.05 end end |
#submit ⇒ Object
Submit the data – equivalent to pressing Enter or Return to submit a form.
87 88 89 90 91 |
# File 'lib/watir/form.rb', line 87 def submit assert_exists @ole_object.invoke('submit') @container.wait end |
#wait(no_sleep = false) ⇒ Object Also known as: waitForIE
103 104 105 |
# File 'lib/watir/form.rb', line 103 def wait(no_sleep=false) @container.wait(no_sleep) end |