watir 1.6.2 → 1.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data/CHANGES +326 -188
  2. data/bin/watir-console +7 -8
  3. data/lib/changes.rb +3 -3
  4. data/lib/license.rb +38 -38
  5. data/lib/readme.rb +140 -140
  6. data/lib/watir/WindowHelper.rb +49 -49
  7. data/lib/watir/camel_case.rb +66 -45
  8. data/lib/watir/clickJSDialog.rb +19 -19
  9. data/lib/watir/close_all.rb +37 -37
  10. data/lib/watir/collections.rb +344 -312
  11. data/lib/watir/container.rb +815 -753
  12. data/lib/watir/contrib/enabled_popup.rb +20 -20
  13. data/lib/watir/contrib/ie-new-process.rb +27 -27
  14. data/lib/watir/contrib/page_checker.rb +29 -29
  15. data/lib/watir/cookiemanager.rb +55 -55
  16. data/lib/watir/core_ext.rb +18 -0
  17. data/lib/watir/datahandler.rb +107 -107
  18. data/lib/watir/dialog.rb +46 -46
  19. data/lib/watir/element.rb +343 -312
  20. data/lib/watir/element_collections.rb +97 -81
  21. data/lib/watir/form.rb +170 -170
  22. data/lib/watir/frame.rb +59 -59
  23. data/lib/watir/ie-class.rb +1009 -1003
  24. data/lib/watir/ie-process.rb +39 -39
  25. data/lib/watir/ie.rb +133 -132
  26. data/lib/watir/image.rb +130 -130
  27. data/lib/watir/input_elements.rb +572 -539
  28. data/lib/watir/irb-history.rb +30 -30
  29. data/lib/watir/link.rb +64 -64
  30. data/lib/watir/locator.rb +176 -161
  31. data/lib/watir/logger.rb +19 -19
  32. data/lib/watir/modal_dialog.rb +122 -122
  33. data/lib/watir/non_control_elements.rb +145 -127
  34. data/lib/watir/page-container.rb +107 -105
  35. data/lib/watir/popup.rb +29 -29
  36. data/lib/watir/process.rb +19 -19
  37. data/lib/watir/screen_capture.rb +115 -115
  38. data/lib/watir/setFileDialog.rb +16 -16
  39. data/lib/watir/table.rb +362 -362
  40. data/lib/watir/utils.rb +19 -19
  41. data/lib/watir/version.rb +5 -5
  42. data/lib/watir/watir_simple.rb +475 -475
  43. data/lib/watir/win32.rb +35 -28
  44. data/lib/watir/win32ole.rb +14 -6
  45. data/lib/watir/winClicker.rb +496 -479
  46. data/unittests/all_tests.rb +10 -10
  47. data/unittests/buttons_xpath_test.rb +69 -69
  48. data/unittests/checkbox_test.rb +179 -176
  49. data/unittests/checkbox_xpath_test.rb +107 -107
  50. data/unittests/core_tests.rb +17 -16
  51. data/unittests/css_test.rb +35 -35
  52. data/unittests/defer_test.rb +46 -46
  53. data/unittests/dialog_test.rb +77 -77
  54. data/unittests/div2_xpath_test.rb +21 -21
  55. data/unittests/div_test.rb +188 -183
  56. data/unittests/div_xpath_test.rb +96 -96
  57. data/unittests/errorchecker_test.rb +22 -22
  58. data/unittests/filefield_test.rb +39 -40
  59. data/unittests/filefield_xpath_test.rb +33 -33
  60. data/unittests/form_test.rb +280 -293
  61. data/unittests/form_xpath_test.rb +252 -253
  62. data/unittests/frame_test.rb +155 -157
  63. data/unittests/google_form_test.rb +15 -15
  64. data/unittests/html/JavascriptClick.html +39 -39
  65. data/unittests/html/blankpage.html +11 -11
  66. data/unittests/html/buttons1.html +40 -40
  67. data/unittests/html/checkboxes1.html +89 -89
  68. data/unittests/html/complex_table.html +36 -36
  69. data/unittests/html/cssTest.html +42 -42
  70. data/unittests/html/depot_store.html +51 -51
  71. data/unittests/html/div.html +93 -93
  72. data/unittests/html/div_xml.html +20 -20
  73. data/unittests/html/fileupload.html +45 -45
  74. data/unittests/html/formTest1.html +38 -38
  75. data/unittests/html/forms2.html +44 -44
  76. data/unittests/html/forms3.html +131 -131
  77. data/unittests/html/forms4.html +27 -27
  78. data/unittests/html/frame_buttons.html +3 -3
  79. data/unittests/html/frame_links.html +3 -3
  80. data/unittests/html/frame_multi.html +4 -4
  81. data/unittests/html/google_india.html +107 -107
  82. data/unittests/html/iframeTest.html +12 -12
  83. data/unittests/html/iframeTest1.html +6 -6
  84. data/unittests/html/iframeTest2.html +5 -5
  85. data/unittests/html/images1.html +66 -66
  86. data/unittests/html/javascriptevents.html +35 -35
  87. data/unittests/html/link_pass.html +10 -10
  88. data/unittests/html/links1.html +38 -38
  89. data/unittests/html/links2.html +10 -10
  90. data/unittests/html/links_multi.html +14 -14
  91. data/unittests/html/list_matters.html +720 -720
  92. data/unittests/html/lists.html +17 -17
  93. data/unittests/html/map_test.html +31 -31
  94. data/unittests/html/modal_dialog.html +10 -10
  95. data/unittests/html/modal_dialog_launcher.html +11 -11
  96. data/unittests/html/nestedFrames.html +6 -6
  97. data/unittests/html/new_browser.html +16 -16
  98. data/unittests/html/pass.html +12 -12
  99. data/unittests/html/popups1.html +59 -59
  100. data/unittests/html/pre.html +27 -27
  101. data/unittests/html/radioButtons1.html +71 -71
  102. data/unittests/html/select_tealeaf.html +54 -54
  103. data/unittests/html/selectboxes1.html +52 -55
  104. data/unittests/html/simple_table.html +26 -26
  105. data/unittests/html/simple_table_buttons.html +104 -104
  106. data/unittests/html/simple_table_columns.html +76 -76
  107. data/unittests/html/table1.html +181 -181
  108. data/unittests/html/tableCell_using_xpath.html +19 -19
  109. data/unittests/html/textarea.html +30 -30
  110. data/unittests/html/textfields1.html +88 -88
  111. data/unittests/html/textsearch.html +44 -44
  112. data/unittests/html/wallofcheckboxes.html +1003 -1003
  113. data/unittests/html/xpath_nbsp.html +12 -12
  114. data/unittests/ie_exists_test.rb +33 -33
  115. data/unittests/ie_mock.rb +94 -94
  116. data/unittests/ie_test.rb +51 -50
  117. data/unittests/images_test.rb +157 -157
  118. data/unittests/images_xpath_test.rb +91 -91
  119. data/unittests/links_multi_test.rb +48 -48
  120. data/unittests/links_test.rb +175 -177
  121. data/unittests/links_xpath_test.rb +39 -39
  122. data/unittests/map_test.rb +98 -98
  123. data/unittests/minmax_test.rb +31 -31
  124. data/unittests/navigate_test.rb +39 -39
  125. data/unittests/nbsp_xpath_test.rb +16 -16
  126. data/unittests/non_core_tests.rb +12 -12
  127. data/unittests/other/WindowLogonExample.rb +27 -27
  128. data/unittests/other/WindowLogonExtra.rb +6 -6
  129. data/unittests/other/all_tests_concurrent.rb +57 -57
  130. data/unittests/{windows → other}/jscriptExtraAlert.rb +6 -6
  131. data/unittests/{windows → other}/jscriptExtraConfirmCancel.rb +6 -6
  132. data/unittests/{windows → other}/jscriptExtraConfirmOk.rb +6 -6
  133. data/unittests/{windows → other}/jscriptPushButton.rb +6 -6
  134. data/unittests/{windows → other}/jscript_test.rb +63 -63
  135. data/unittests/other/navigate_exception_test.rb +24 -24
  136. data/unittests/other/rexml_unit_test.rb +27 -24
  137. data/unittests/other/screen_capture_test.rb +54 -54
  138. data/unittests/other/testcase_method_order_test.rb +35 -35
  139. data/unittests/other/testcase_verify_test.rb +24 -24
  140. data/unittests/other/wait_until_test.rb +99 -99
  141. data/unittests/pagecontainstext_test.rb +69 -69
  142. data/unittests/parent_child_test.rb +43 -43
  143. data/unittests/perf_test.rb +20 -20
  144. data/unittests/popups_test.rb +43 -43
  145. data/unittests/pre_test.rb +53 -53
  146. data/unittests/radios_test.rb +212 -212
  147. data/unittests/radios_xpath_test.rb +101 -101
  148. data/unittests/security_setting_test.rb +23 -23
  149. data/unittests/selectbox_test.rb +148 -139
  150. data/unittests/selectbox_xpath_test.rb +113 -113
  151. data/unittests/setup.rb +77 -75
  152. data/unittests/speed_settings_test.rb +67 -65
  153. data/unittests/table_cell_using_xpath_test.rb +35 -35
  154. data/unittests/table_test.rb +376 -362
  155. data/unittests/table_xpath_test.rb +110 -110
  156. data/unittests/test_tests.rb +9 -9
  157. data/unittests/textarea_test.rb +92 -92
  158. data/unittests/textarea_xpath_test.rb +78 -78
  159. data/unittests/textfield_for_ch_char_test.rb +31 -29
  160. data/unittests/textfields_test.rb +218 -218
  161. data/unittests/textfields_xpath_test.rb +111 -111
  162. data/unittests/window_tests.rb +10 -7
  163. data/unittests/windows/attach_to_existing_window_test.rb +53 -52
  164. data/unittests/windows/attach_to_new_window_test.rb +83 -82
  165. data/unittests/windows/close_window_test.rb +20 -20
  166. data/unittests/windows/frame_links_test.rb +25 -25
  167. data/unittests/windows/ie-each_test.rb +47 -47
  168. data/unittests/windows/iedialog_test.rb +54 -54
  169. data/unittests/windows/js_events_test.rb +55 -55
  170. data/unittests/windows/modal_dialog_test.rb +128 -126
  171. data/unittests/windows/new_test.rb +57 -55
  172. data/unittests/windows/open_close_test.rb +18 -18
  173. data/unittests/windows/send_keys_test.rb +33 -32
  174. data/unittests/xpath_tests.rb +10 -10
  175. metadata +20 -20
  176. data/lib/watir/contrib/visible.rb +0 -47
  177. data/unittests/iostring.rb +0 -30
  178. data/unittests/iostring_test.rb +0 -48
@@ -1,46 +1,67 @@
1
- # These are provided for backwards compatability with Watir 1.1
2
-
3
- module Watir
4
- module Container
5
- alias waitForIE wait
6
- alias fileField file_field
7
- alias textField text_field
8
- alias selectBox select_list
9
- alias checkBox checkbox
10
- end
11
- class IE
12
- alias getStatus status
13
- alias getDocument document
14
- alias pageContainsText contains_text
15
- alias waitForIE wait
16
- alias getHTML html
17
- alias getText text
18
- alias showFrames show_frames
19
- alias showForms show_forms
20
- alias showImages show_images
21
- alias showLinks show_links
22
- alias showActive show_active
23
- alias showAllObjects show_all_objects
24
- def getIE; @ie; end
25
-
26
- end
27
- class Element
28
- alias getOLEObject ole_object
29
- alias fireEvent fire_event
30
- alias innerText text
31
- alias afterText after_text
32
- alias beforeText before_text
33
- end
34
- class Frame
35
- alias getDocument document
36
- alias waitForIE wait
37
- end
38
- class Form
39
- alias waitForIE wait
40
- end
41
- class TextField
42
- alias readOnly? :readonly?
43
- alias getContents value
44
- alias maxLength maxlength
45
- end
1
+ # These are provided for backwards compatability with Watir 1.1
2
+
3
+ module Watir
4
+ module Container
5
+ alias waitForIE wait
6
+ alias fileField file_field
7
+ alias textField text_field
8
+ alias selectBox select_list
9
+ alias checkBox checkbox
10
+ end
11
+ class IE
12
+ alias getStatus status
13
+ alias getDocument document
14
+ alias pageContainsText contains_text
15
+ alias waitForIE wait
16
+ alias getHTML html
17
+ alias getText text
18
+ alias showFrames show_frames
19
+ alias showForms show_forms
20
+ alias showImages show_images
21
+ alias showLinks show_links
22
+ alias showActive show_active
23
+ alias showAllObjects show_all_objects
24
+ def getIE; @ie; end
25
+
26
+ end
27
+ class Element
28
+ alias getOLEObject ole_object
29
+ alias fireEvent fire_event
30
+ alias innerText text
31
+ alias afterText after_text
32
+ alias beforeText before_text
33
+ end
34
+ class Frame
35
+ alias getDocument document
36
+ alias waitForIE wait
37
+ end
38
+ class Form
39
+ alias waitForIE wait
40
+ end
41
+
42
+
43
+ class Image
44
+ alias fileCreatedDate file_created_date
45
+ alias fileSize file_size
46
+ alias hasLoaded? loaded?
47
+ end
48
+
49
+ class RadioCheckCommon
50
+ alias getState set?
51
+ alias isSet? set?
52
+ end
53
+
54
+ class TextField
55
+ alias readOnly? :readonly?
56
+ alias getContents value
57
+ alias maxLength maxlength
58
+ alias dragContentsTo drag_contents_to
59
+ end
60
+
61
+ class SelectList
62
+ alias getAllContents options
63
+ alias getSelectedItems selected_options
64
+ alias clearSelection clear
65
+ alias includes? include?
66
+ end
46
67
  end
@@ -1,19 +1,19 @@
1
- #
2
- # clickJSDialog.rb
3
- #
4
- #
5
- # This file contains the JS clicker when it runs as a separate process
6
-
7
- $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..'))
8
- puts $LOAD_PATH
9
- require 'watir/winClicker'
10
-
11
- button = "OK"
12
- button = ARGV[0] unless ARGV[0] == nil
13
- sleepTime = 0
14
- sleepTime = ARGV[1] unless ARGV[1] == nil
15
-
16
-
17
- clicker= WinClicker.new
18
- result = clicker.clickJavaScriptDialog( button )
19
- clicker = nil
1
+ #
2
+ # clickJSDialog.rb
3
+ #
4
+ #
5
+ # This file contains the JS clicker when it runs as a separate process
6
+
7
+ $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..'))
8
+ puts $LOAD_PATH
9
+ require 'watir/winClicker'
10
+
11
+ button = "OK"
12
+ button = ARGV[0] unless ARGV[0] == nil
13
+ sleepTime = 0
14
+ sleepTime = ARGV[1] unless ARGV[1] == nil
15
+
16
+
17
+ clicker= WinClicker.new
18
+ result = clicker.clickJavaScriptDialog( button )
19
+ clicker = nil
@@ -1,38 +1,38 @@
1
- require 'watir/ie'
2
-
3
- module Watir
4
- class IE
5
- # close all ie browser windows
6
- def self.close_all
7
- close_all_but nil
8
- end
9
- # find other ie browser windows and close them
10
- def close_others
11
- IE.close_all_but self
12
- end
13
- private
14
- def self.close_all_but(except=nil)
15
- Watir::IE.each do |ie|
16
- ie.close_modal
17
- ie.close unless except and except.hwnd == ie.hwnd
18
- end
19
- sleep 1.0 # replace with polling for window count to be zero?
20
- end
21
- public
22
- # close modal dialog. unlike IE#modal_dialog.close, does not wait for dialog
23
- # to appear and does not raise exception if no window is found.
24
- # returns true if modal was found and close, otherwise false
25
- def close_modal
26
- begin
27
- original_attach_timeout = IE.attach_timeout
28
- IE.attach_timeout = 0
29
- self.modal_dialog.close
30
- true
31
- rescue NoMatchingWindowFoundException, TimeOutException
32
- false
33
- ensure
34
- IE.attach_timeout = original_attach_timeout
35
- end
36
- end
37
- end
1
+ require 'watir/ie'
2
+
3
+ module Watir
4
+ class IE
5
+ # close all ie browser windows
6
+ def self.close_all
7
+ close_all_but nil
8
+ end
9
+ # find other ie browser windows and close them
10
+ def close_others
11
+ IE.close_all_but self
12
+ end
13
+ private
14
+ def self.close_all_but(except=nil)
15
+ Watir::IE.each do |ie|
16
+ ie.close_modal
17
+ ie.close unless except and except.hwnd == ie.hwnd
18
+ end
19
+ sleep 1.0 # replace with polling for window count to be zero?
20
+ end
21
+ public
22
+ # close modal dialog. unlike IE#modal_dialog.close, does not wait for dialog
23
+ # to appear and does not raise exception if no window is found.
24
+ # returns true if modal was found and close, otherwise false
25
+ def close_modal
26
+ begin
27
+ original_attach_timeout = IE.attach_timeout
28
+ IE.attach_timeout = 0
29
+ self.modal_dialog.close
30
+ true
31
+ rescue NoMatchingWindowFoundException, TimeOutException
32
+ false
33
+ ensure
34
+ IE.attach_timeout = original_attach_timeout
35
+ end
36
+ end
37
+ end
38
38
  end
@@ -1,312 +1,344 @@
1
- module Watir
2
- #--
3
- # These classes are not for public consumption, so we switch off rdoc
4
-
5
- # presumes element_class or element_tag is defined
6
- # for subclasses of ElementCollections
7
- module CommonCollection
8
- def element_tag
9
- element_class::TAG
10
- end
11
- def length
12
- @container.document.getElementsByTagName(element_tag).length
13
- end
14
- end
15
-
16
- # This class is used as part of the .show method of the iterators class
17
- # it would not normally be used by a user
18
- class AttributeLengthPairs
19
-
20
- # This class is used as part of the .show method of the iterators class
21
- # it would not normally be used by a user
22
- class AttributeLengthHolder
23
- attr_accessor :attribute
24
- attr_accessor :length
25
-
26
- def initialize(attrib, length)
27
- @attribute = attrib
28
- @length = length
29
- end
30
- end
31
-
32
- def initialize(attrib=nil, length=nil)
33
- @attr=[]
34
- add(attrib, length) if attrib
35
- @index_counter = 0
36
- end
37
-
38
- # BUG: Untested. (Null implementation passes all tests.)
39
- def add(attrib, length)
40
- @attr << AttributeLengthHolder.new(attrib, length)
41
- end
42
-
43
- def delete(attrib)
44
- item_to_delete = nil
45
- @attr.each_with_index do |e,i|
46
- item_to_delete = i if e.attribute == attrib
47
- end
48
- @attr.delete_at(item_to_delete) unless item_to_delete == nil
49
- end
50
-
51
- def next
52
- temp = @attr[@index_counter]
53
- @index_counter += 1
54
- return temp
55
- end
56
-
57
- def each
58
- 0.upto(@attr.length-1) { |i | yield @attr[i] }
59
- end
60
- end
61
-
62
- # resume rdoc
63
- #++
64
-
65
- # this class accesses the buttons in the document as a collection
66
- # it would normally only be accessed by the Watir::Container#buttons method
67
- class Buttons < ElementCollections
68
- def element_class; Button; end
69
- def length
70
- get_length_of_input_objects(["button", "submit", "image"])
71
- end
72
-
73
- private
74
- def set_show_items
75
- super
76
- @show_attributes.add("disabled", 9)
77
- @show_attributes.add("value", 20)
78
- end
79
- end
80
-
81
- # this class accesses the file fields in the document as a collection
82
- # normal access is via the Container#file_fields method
83
- class FileFields < ElementCollections
84
- def element_class; FileField; end
85
- def length
86
- get_length_of_input_objects(["file"])
87
- end
88
-
89
- private
90
- def set_show_items
91
- super
92
- @show_attributes.add("disabled", 9)
93
- @show_attributes.add("value", 20)
94
- end
95
- end
96
-
97
- # this class accesses the check boxes in the document as a collection
98
- # Normally a user would not need to create this object as it is returned by the Watir::Container#checkboxes method
99
- class CheckBoxes < ElementCollections
100
- def element_class; CheckBox; end
101
- def length
102
- get_length_of_input_objects("checkbox")
103
- end
104
-
105
- private
106
- def iterator_object(i)
107
- @container.checkbox(:index, i + 1)
108
- end
109
- end
110
-
111
- # this class accesses the radio buttons in the document as a collection
112
- # Normally a user would not need to create this object as it is returned by the Watir::Container#radios method
113
- class Radios < ElementCollections
114
- def element_class; Radio; end
115
- def length
116
- get_length_of_input_objects("radio")
117
- end
118
-
119
- private
120
- def iterator_object(i)
121
- @container.radio(:index, i + 1)
122
- end
123
- end
124
-
125
- # this class accesses the select boxes in the document as a collection
126
- # Normally a user would not need to create this object as it is returned by the Watir::Container#select_lists method
127
- class SelectLists < ElementCollections
128
- include CommonCollection
129
- def element_class; SelectList; end
130
- def element_tag; 'SELECT'; end
131
- end
132
-
133
- # this class accesses the links in the document as a collection
134
- # Normally a user would not need to create this object as it is returned by the Watir::Container#links method
135
- class Links < ElementCollections
136
- include CommonCollection
137
- def element_class; Link; end
138
- def element_tag; 'A'; end
139
-
140
- private
141
- def set_show_items
142
- super
143
- @show_attributes.add("href", 60)
144
- @show_attributes.add("innerText", 60)
145
- end
146
- end
147
-
148
- class Lis < ElementCollections
149
- include CommonCollection
150
- def element_class; Li; end
151
-
152
- def set_show_items
153
- super
154
- @show_attributes.delete( "name")
155
- @show_attributes.add( "className" , 20)
156
- end
157
- end
158
-
159
- # this class accesses the maps in the document as a collection
160
- # Normally a user would not need to create this object as it is returned by the Watir::Container#maps method
161
- class Maps < ElementCollections
162
- include CommonCollection
163
- def element_class; Map; end
164
- def element_tag; 'MAP'; end
165
- end
166
-
167
-
168
- # this class accesses the areas in the document as a collection
169
- # Normally a user would not need to create this object as it is returned by the Watir::Container#areas method
170
- class Areas < ElementCollections
171
- include CommonCollection
172
- def element_class; Area; end
173
- def element_tag; 'AREA'; end
174
- end
175
-
176
- # this class collects the images in the container
177
- # An instance is returned by Watir::Container#images
178
- class Images < ElementCollections
179
- def element_class; Image; end
180
- def length
181
- all = @container.document.all
182
- imgs = []
183
- all.each{|n| imgs << n if n.nodeName == "IMG"}
184
- imgs.length
185
- end
186
-
187
- private
188
- def set_show_items
189
- super
190
- @show_attributes.add("src", 60)
191
- @show_attributes.add("alt", 30)
192
- end
193
- end
194
-
195
- # this class accesses the text fields in the document as a collection
196
- # Normally a user would not need to create this object as it is returned by the Watir::Container#text_fields method
197
- class TextFields < ElementCollections
198
- def element_class; TextField; end
199
- def length
200
- # text areas are also included in the TextFields, but we need to get them seperately
201
- get_length_of_input_objects(["text", "password"]) +
202
- @container.document.getElementsByTagName("textarea").length
203
- end
204
- end
205
-
206
- # this class accesses the hidden fields in the document as a collection
207
- # Normally a user would not need to create this object as it is returned by the Watir::Container#hiddens method
208
- class Hiddens < ElementCollections
209
- def element_class; Hidden; end
210
- def length
211
- get_length_of_input_objects("hidden")
212
- end
213
- end
214
-
215
- # this class accesses the text fields in the document as a collection
216
- # Normally a user would not need to create this object as it is returned by the Watir::Container#tables method
217
- class Tables < ElementCollections
218
- include CommonCollection
219
- def element_class; Table; end
220
- def element_tag; 'TABLE'; end
221
-
222
- private
223
- def set_show_items
224
- super
225
- @show_attributes.delete("name")
226
- end
227
- end
228
- # this class accesses the table rows in the document as a collection
229
- # Normally a user would not need to create this object as it is returned by the Watir::Container#rows method
230
- class TableRows < ElementCollections
231
- include CommonCollection
232
- def element_class; TableRow; end
233
- def element_tag; 'TR'; end
234
- end
235
- # this class accesses the table cells in the document as a collection
236
- # Normally a user would not need to create this object as it is returned by the Watir::Container#cells method
237
- class TableCells < ElementCollections
238
- include CommonCollection
239
- def element_class; TableCell; end
240
- def element_tag; 'TD'; end
241
- end
242
- # this class accesses the labels in the document as a collection
243
- # Normally a user would not need to create this object as it is returned by the Watir::Container#labels method
244
- class Labels < ElementCollections
245
- include CommonCollection
246
- def element_class; Label; end
247
- def element_tag; 'LABEL'; end
248
-
249
- private
250
- def set_show_items
251
- super
252
- @show_attributes.add("htmlFor", 20)
253
- end
254
- end
255
-
256
- # this class accesses the pre tags in the document as a collection
257
- # Normally a user would not need to create this object as it is returned by the Watir::Container#pres method
258
- class Pres < ElementCollections
259
- include CommonCollection
260
- def element_class; Pre; end
261
-
262
- private
263
- def set_show_items
264
- super
265
- @show_attributes.delete("name")
266
- @show_attributes.add("className", 20)
267
- end
268
- end
269
-
270
- # this class accesses the p tags in the document as a collection
271
- # Normally a user would not need to create this object as it is returned by the Watir::Container#ps method
272
- class Ps < ElementCollections
273
- include CommonCollection
274
- def element_class; P; end
275
-
276
- private
277
- def set_show_items
278
- super
279
- @show_attributes.delete("name")
280
- @show_attributes.add("className", 20)
281
- end
282
-
283
- end
284
- # this class accesses the spans in the document as a collection
285
- # Normally a user would not need to create this object as it is returned by the Watir::Container#spans method
286
- class Spans < ElementCollections
287
- include CommonCollection
288
- def element_class; Span; end
289
-
290
- private
291
- def set_show_items
292
- super
293
- @show_attributes.delete("name")
294
- @show_attributes.add("className", 20)
295
- end
296
- end
297
-
298
- # this class accesses the divs in the document as a collection
299
- # Normally a user would not need to create this object as it is returned by the Watir::Container#divs method
300
- class Divs < ElementCollections
301
- include CommonCollection
302
- def element_class; Div; end
303
-
304
- private
305
- def set_show_items
306
- super
307
- @show_attributes.delete("name")
308
- @show_attributes.add("className", 20)
309
- end
310
- end
311
-
312
- end
1
+ module Watir
2
+ #--
3
+ # These classes are not for public consumption, so we switch off rdoc
4
+
5
+ # presumes element_class or element_tag is defined
6
+ # for subclasses of ElementCollections
7
+ module CommonCollection
8
+ def element_tag
9
+ element_class::TAG
10
+ end
11
+
12
+ def length
13
+ @container.document.getElementsByTagName(element_tag).length
14
+ end
15
+ alias_method :size, :length
16
+ end
17
+
18
+ # This class is used as part of the .show method of the iterators class
19
+ # it would not normally be used by a user
20
+ class AttributeLengthPairs
21
+
22
+ # This class is used as part of the .show method of the iterators class
23
+ # it would not normally be used by a user
24
+ class AttributeLengthHolder
25
+ attr_accessor :attribute
26
+ attr_accessor :length
27
+
28
+ def initialize(attrib, length)
29
+ @attribute = attrib
30
+ @length = length
31
+ end
32
+ end
33
+
34
+ def initialize(attrib=nil, length=nil)
35
+ @attr=[]
36
+ add(attrib, length) if attrib
37
+ @index_counter = 0
38
+ end
39
+
40
+ # BUG: Untested. (Null implementation passes all tests.)
41
+ def add(attrib, length)
42
+ @attr << AttributeLengthHolder.new(attrib, length)
43
+ end
44
+
45
+ def delete(attrib)
46
+ item_to_delete = nil
47
+ @attr.each_with_index do |e,i|
48
+ item_to_delete = i if e.attribute == attrib
49
+ end
50
+ @attr.delete_at(item_to_delete) unless item_to_delete == nil
51
+ end
52
+
53
+ def next
54
+ temp = @attr[@index_counter]
55
+ @index_counter += 1
56
+ return temp
57
+ end
58
+
59
+ def each
60
+ 0.upto(@attr.length-1) { |i | yield @attr[i] }
61
+ end
62
+ end
63
+
64
+ # resume rdoc
65
+ #++
66
+
67
+ # this class accesses the buttons in the document as a collection
68
+ # it would normally only be accessed by the Watir::Container#buttons method
69
+ class Buttons < ElementCollections
70
+ def element_class; Button; end
71
+ def length
72
+ get_length_of_input_objects(["button", "submit", "image"])
73
+ end
74
+
75
+ private
76
+ def set_show_items
77
+ super
78
+ @show_attributes.add("disabled", 9)
79
+ @show_attributes.add("value", 20)
80
+ end
81
+ end
82
+
83
+ # this class accesses the file fields in the document as a collection
84
+ # normal access is via the Container#file_fields method
85
+ class FileFields < ElementCollections
86
+ def element_class; FileField; end
87
+ def length
88
+ get_length_of_input_objects(["file"])
89
+ end
90
+
91
+ private
92
+ def set_show_items
93
+ super
94
+ @show_attributes.add("disabled", 9)
95
+ @show_attributes.add("value", 20)
96
+ end
97
+ end
98
+
99
+ # this class accesses the check boxes in the document as a collection
100
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#checkboxes method
101
+ class CheckBoxes < ElementCollections
102
+ def element_class; CheckBox; end
103
+ def length
104
+ get_length_of_input_objects("checkbox")
105
+ end
106
+
107
+ private
108
+ def iterator_object(i)
109
+ @container.checkbox(:index, i + 1)
110
+ end
111
+ end
112
+
113
+ # this class accesses the radio buttons in the document as a collection
114
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#radios method
115
+ class Radios < ElementCollections
116
+ def element_class; Radio; end
117
+ def length
118
+ get_length_of_input_objects("radio")
119
+ end
120
+
121
+ private
122
+ def iterator_object(i)
123
+ @container.radio(:index, i + 1)
124
+ end
125
+ end
126
+
127
+ # this class accesses the select boxes in the document as a collection
128
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#select_lists method
129
+ class SelectLists < ElementCollections
130
+ include CommonCollection
131
+ def element_class; SelectList; end
132
+ def element_tag; 'SELECT'; end
133
+ end
134
+
135
+ # this class accesses the links in the document as a collection
136
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#links method
137
+ class Links < ElementCollections
138
+ include CommonCollection
139
+ def element_class; Link; end
140
+ def element_tag; 'A'; end
141
+
142
+ private
143
+ def set_show_items
144
+ super
145
+ @show_attributes.add("href", 60)
146
+ @show_attributes.add("innerText", 60)
147
+ end
148
+ end
149
+
150
+ class Lis < ElementCollections
151
+ include CommonCollection
152
+ def element_class; Li; end
153
+
154
+ def set_show_items
155
+ super
156
+ @show_attributes.delete( "name")
157
+ @show_attributes.add( "className" , 20)
158
+ end
159
+ end
160
+
161
+ # this class accesses the maps in the document as a collection
162
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#maps method
163
+ class Maps < ElementCollections
164
+ include CommonCollection
165
+ def element_class; Map; end
166
+ def element_tag; 'MAP'; end
167
+ end
168
+
169
+
170
+ # this class accesses the areas in the document as a collection
171
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#areas method
172
+ class Areas < ElementCollections
173
+ include CommonCollection
174
+ def element_class; Area; end
175
+ def element_tag; 'AREA'; end
176
+ end
177
+
178
+ # this class collects the images in the container
179
+ # An instance is returned by Watir::Container#images
180
+ class Images < ElementCollections
181
+ def element_class; Image; end
182
+ def length
183
+ all = @container.document.all
184
+ imgs = []
185
+ all.each{|n| imgs << n if n.nodeName == "IMG"}
186
+ imgs.length
187
+ end
188
+
189
+ private
190
+ def set_show_items
191
+ super
192
+ @show_attributes.add("src", 60)
193
+ @show_attributes.add("alt", 30)
194
+ end
195
+ end
196
+
197
+ # this class accesses the text fields in the document as a collection
198
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#text_fields method
199
+ class TextFields < ElementCollections
200
+ def element_class; TextField; end
201
+ def length
202
+ # text areas are also included in the TextFields, but we need to get them seperately
203
+ get_length_of_input_objects(["text", "password"]) +
204
+ @container.document.getElementsByTagName("textarea").length
205
+ end
206
+ end
207
+
208
+ # this class accesses the hidden fields in the document as a collection
209
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#hiddens method
210
+ class Hiddens < ElementCollections
211
+ def element_class; Hidden; end
212
+ def length
213
+ get_length_of_input_objects("hidden")
214
+ end
215
+ end
216
+
217
+ # this class accesses the text fields in the document as a collection
218
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#tables method
219
+ class Tables < ElementCollections
220
+ include CommonCollection
221
+ def element_class; Table; end
222
+ def element_tag; 'TABLE'; end
223
+
224
+ private
225
+ def set_show_items
226
+ super
227
+ @show_attributes.delete("name")
228
+ end
229
+ end
230
+ # this class accesses the table rows in the document as a collection
231
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#rows method
232
+ class TableRows < ElementCollections
233
+ include CommonCollection
234
+ def element_class; TableRow; end
235
+ def element_tag; 'TR'; end
236
+ end
237
+ # this class accesses the table cells in the document as a collection
238
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#cells method
239
+ class TableCells < ElementCollections
240
+ include CommonCollection
241
+ def element_class; TableCell; end
242
+ def element_tag; 'TD'; end
243
+ end
244
+ # this class accesses the labels in the document as a collection
245
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#labels method
246
+ class Labels < ElementCollections
247
+ include CommonCollection
248
+ def element_class; Label; end
249
+ def element_tag; 'LABEL'; end
250
+
251
+ private
252
+ def set_show_items
253
+ super
254
+ @show_attributes.add("htmlFor", 20)
255
+ end
256
+ end
257
+
258
+ # this class accesses the pre tags in the document as a collection
259
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#pres method
260
+ class Pres < ElementCollections
261
+ include CommonCollection
262
+ def element_class; Pre; end
263
+
264
+ private
265
+ def set_show_items
266
+ super
267
+ @show_attributes.delete("name")
268
+ @show_attributes.add("className", 20)
269
+ end
270
+ end
271
+
272
+ # this class accesses the p tags in the document as a collection
273
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#ps method
274
+ class Ps < ElementCollections
275
+ include CommonCollection
276
+ def element_class; P; end
277
+
278
+ private
279
+ def set_show_items
280
+ super
281
+ @show_attributes.delete("name")
282
+ @show_attributes.add("className", 20)
283
+ end
284
+
285
+ end
286
+ # this class accesses the spans in the document as a collection
287
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#spans method
288
+ class Spans < ElementCollections
289
+ include CommonCollection
290
+ def element_class; Span; end
291
+
292
+ private
293
+ def set_show_items
294
+ super
295
+ @show_attributes.delete("name")
296
+ @show_attributes.add("className", 20)
297
+ end
298
+ end
299
+
300
+ # this class accesses the divs in the document as a collection
301
+ # Normally a user would not need to create this object as it is returned by the Watir::Container#divs method
302
+ class Divs < ElementCollections
303
+ include CommonCollection
304
+ def element_class; Div; end
305
+
306
+ private
307
+ def set_show_items
308
+ super
309
+ @show_attributes.delete("name")
310
+ @show_attributes.add("className", 20)
311
+ end
312
+ end
313
+
314
+ class Dls < ElementCollections
315
+ include CommonCollection
316
+ def element_class; Dl; end
317
+ def element_tag; Dl::TAG; end
318
+ end
319
+
320
+ class Dts < ElementCollections
321
+ include CommonCollection
322
+ def element_class; Dt; end
323
+ def element_tag; Dt::TAG; end
324
+ end
325
+
326
+ class Dds < ElementCollections
327
+ include CommonCollection
328
+ def element_class; Dd; end
329
+ def element_tag; Dd::TAG; end
330
+ end
331
+
332
+ class Strongs < ElementCollections
333
+ include CommonCollection
334
+ def element_class; Strong; end
335
+ def element_tag; Strong::TAG; end
336
+ end
337
+
338
+ class Ems < ElementCollections
339
+ include CommonCollection
340
+ def element_class; Em; end
341
+ def element_tag; Em::TAG; end
342
+ end
343
+
344
+ end