watir 1.6.2 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +326 -188
- data/bin/watir-console +7 -8
- data/lib/changes.rb +3 -3
- data/lib/license.rb +38 -38
- data/lib/readme.rb +140 -140
- data/lib/watir/WindowHelper.rb +49 -49
- data/lib/watir/camel_case.rb +66 -45
- data/lib/watir/clickJSDialog.rb +19 -19
- data/lib/watir/close_all.rb +37 -37
- data/lib/watir/collections.rb +344 -312
- data/lib/watir/container.rb +815 -753
- data/lib/watir/contrib/enabled_popup.rb +20 -20
- data/lib/watir/contrib/ie-new-process.rb +27 -27
- data/lib/watir/contrib/page_checker.rb +29 -29
- data/lib/watir/cookiemanager.rb +55 -55
- data/lib/watir/core_ext.rb +18 -0
- data/lib/watir/datahandler.rb +107 -107
- data/lib/watir/dialog.rb +46 -46
- data/lib/watir/element.rb +343 -312
- data/lib/watir/element_collections.rb +97 -81
- data/lib/watir/form.rb +170 -170
- data/lib/watir/frame.rb +59 -59
- data/lib/watir/ie-class.rb +1009 -1003
- data/lib/watir/ie-process.rb +39 -39
- data/lib/watir/ie.rb +133 -132
- data/lib/watir/image.rb +130 -130
- data/lib/watir/input_elements.rb +572 -539
- data/lib/watir/irb-history.rb +30 -30
- data/lib/watir/link.rb +64 -64
- data/lib/watir/locator.rb +176 -161
- data/lib/watir/logger.rb +19 -19
- data/lib/watir/modal_dialog.rb +122 -122
- data/lib/watir/non_control_elements.rb +145 -127
- data/lib/watir/page-container.rb +107 -105
- data/lib/watir/popup.rb +29 -29
- data/lib/watir/process.rb +19 -19
- data/lib/watir/screen_capture.rb +115 -115
- data/lib/watir/setFileDialog.rb +16 -16
- data/lib/watir/table.rb +362 -362
- data/lib/watir/utils.rb +19 -19
- data/lib/watir/version.rb +5 -5
- data/lib/watir/watir_simple.rb +475 -475
- data/lib/watir/win32.rb +35 -28
- data/lib/watir/win32ole.rb +14 -6
- data/lib/watir/winClicker.rb +496 -479
- data/unittests/all_tests.rb +10 -10
- data/unittests/buttons_xpath_test.rb +69 -69
- data/unittests/checkbox_test.rb +179 -176
- data/unittests/checkbox_xpath_test.rb +107 -107
- data/unittests/core_tests.rb +17 -16
- data/unittests/css_test.rb +35 -35
- data/unittests/defer_test.rb +46 -46
- data/unittests/dialog_test.rb +77 -77
- data/unittests/div2_xpath_test.rb +21 -21
- data/unittests/div_test.rb +188 -183
- data/unittests/div_xpath_test.rb +96 -96
- data/unittests/errorchecker_test.rb +22 -22
- data/unittests/filefield_test.rb +39 -40
- data/unittests/filefield_xpath_test.rb +33 -33
- data/unittests/form_test.rb +280 -293
- data/unittests/form_xpath_test.rb +252 -253
- data/unittests/frame_test.rb +155 -157
- data/unittests/google_form_test.rb +15 -15
- data/unittests/html/JavascriptClick.html +39 -39
- data/unittests/html/blankpage.html +11 -11
- data/unittests/html/buttons1.html +40 -40
- data/unittests/html/checkboxes1.html +89 -89
- data/unittests/html/complex_table.html +36 -36
- data/unittests/html/cssTest.html +42 -42
- data/unittests/html/depot_store.html +51 -51
- data/unittests/html/div.html +93 -93
- data/unittests/html/div_xml.html +20 -20
- data/unittests/html/fileupload.html +45 -45
- data/unittests/html/formTest1.html +38 -38
- data/unittests/html/forms2.html +44 -44
- data/unittests/html/forms3.html +131 -131
- data/unittests/html/forms4.html +27 -27
- data/unittests/html/frame_buttons.html +3 -3
- data/unittests/html/frame_links.html +3 -3
- data/unittests/html/frame_multi.html +4 -4
- data/unittests/html/google_india.html +107 -107
- data/unittests/html/iframeTest.html +12 -12
- data/unittests/html/iframeTest1.html +6 -6
- data/unittests/html/iframeTest2.html +5 -5
- data/unittests/html/images1.html +66 -66
- data/unittests/html/javascriptevents.html +35 -35
- data/unittests/html/link_pass.html +10 -10
- data/unittests/html/links1.html +38 -38
- data/unittests/html/links2.html +10 -10
- data/unittests/html/links_multi.html +14 -14
- data/unittests/html/list_matters.html +720 -720
- data/unittests/html/lists.html +17 -17
- data/unittests/html/map_test.html +31 -31
- data/unittests/html/modal_dialog.html +10 -10
- data/unittests/html/modal_dialog_launcher.html +11 -11
- data/unittests/html/nestedFrames.html +6 -6
- data/unittests/html/new_browser.html +16 -16
- data/unittests/html/pass.html +12 -12
- data/unittests/html/popups1.html +59 -59
- data/unittests/html/pre.html +27 -27
- data/unittests/html/radioButtons1.html +71 -71
- data/unittests/html/select_tealeaf.html +54 -54
- data/unittests/html/selectboxes1.html +52 -55
- data/unittests/html/simple_table.html +26 -26
- data/unittests/html/simple_table_buttons.html +104 -104
- data/unittests/html/simple_table_columns.html +76 -76
- data/unittests/html/table1.html +181 -181
- data/unittests/html/tableCell_using_xpath.html +19 -19
- data/unittests/html/textarea.html +30 -30
- data/unittests/html/textfields1.html +88 -88
- data/unittests/html/textsearch.html +44 -44
- data/unittests/html/wallofcheckboxes.html +1003 -1003
- data/unittests/html/xpath_nbsp.html +12 -12
- data/unittests/ie_exists_test.rb +33 -33
- data/unittests/ie_mock.rb +94 -94
- data/unittests/ie_test.rb +51 -50
- data/unittests/images_test.rb +157 -157
- data/unittests/images_xpath_test.rb +91 -91
- data/unittests/links_multi_test.rb +48 -48
- data/unittests/links_test.rb +175 -177
- data/unittests/links_xpath_test.rb +39 -39
- data/unittests/map_test.rb +98 -98
- data/unittests/minmax_test.rb +31 -31
- data/unittests/navigate_test.rb +39 -39
- data/unittests/nbsp_xpath_test.rb +16 -16
- data/unittests/non_core_tests.rb +12 -12
- data/unittests/other/WindowLogonExample.rb +27 -27
- data/unittests/other/WindowLogonExtra.rb +6 -6
- data/unittests/other/all_tests_concurrent.rb +57 -57
- data/unittests/{windows → other}/jscriptExtraAlert.rb +6 -6
- data/unittests/{windows → other}/jscriptExtraConfirmCancel.rb +6 -6
- data/unittests/{windows → other}/jscriptExtraConfirmOk.rb +6 -6
- data/unittests/{windows → other}/jscriptPushButton.rb +6 -6
- data/unittests/{windows → other}/jscript_test.rb +63 -63
- data/unittests/other/navigate_exception_test.rb +24 -24
- data/unittests/other/rexml_unit_test.rb +27 -24
- data/unittests/other/screen_capture_test.rb +54 -54
- data/unittests/other/testcase_method_order_test.rb +35 -35
- data/unittests/other/testcase_verify_test.rb +24 -24
- data/unittests/other/wait_until_test.rb +99 -99
- data/unittests/pagecontainstext_test.rb +69 -69
- data/unittests/parent_child_test.rb +43 -43
- data/unittests/perf_test.rb +20 -20
- data/unittests/popups_test.rb +43 -43
- data/unittests/pre_test.rb +53 -53
- data/unittests/radios_test.rb +212 -212
- data/unittests/radios_xpath_test.rb +101 -101
- data/unittests/security_setting_test.rb +23 -23
- data/unittests/selectbox_test.rb +148 -139
- data/unittests/selectbox_xpath_test.rb +113 -113
- data/unittests/setup.rb +77 -75
- data/unittests/speed_settings_test.rb +67 -65
- data/unittests/table_cell_using_xpath_test.rb +35 -35
- data/unittests/table_test.rb +376 -362
- data/unittests/table_xpath_test.rb +110 -110
- data/unittests/test_tests.rb +9 -9
- data/unittests/textarea_test.rb +92 -92
- data/unittests/textarea_xpath_test.rb +78 -78
- data/unittests/textfield_for_ch_char_test.rb +31 -29
- data/unittests/textfields_test.rb +218 -218
- data/unittests/textfields_xpath_test.rb +111 -111
- data/unittests/window_tests.rb +10 -7
- data/unittests/windows/attach_to_existing_window_test.rb +53 -52
- data/unittests/windows/attach_to_new_window_test.rb +83 -82
- data/unittests/windows/close_window_test.rb +20 -20
- data/unittests/windows/frame_links_test.rb +25 -25
- data/unittests/windows/ie-each_test.rb +47 -47
- data/unittests/windows/iedialog_test.rb +54 -54
- data/unittests/windows/js_events_test.rb +55 -55
- data/unittests/windows/modal_dialog_test.rb +128 -126
- data/unittests/windows/new_test.rb +57 -55
- data/unittests/windows/open_close_test.rb +18 -18
- data/unittests/windows/send_keys_test.rb +33 -32
- data/unittests/xpath_tests.rb +10 -10
- metadata +20 -20
- data/lib/watir/contrib/visible.rb +0 -47
- data/unittests/iostring.rb +0 -30
- data/unittests/iostring_test.rb +0 -48
data/lib/watir/camel_case.rb
CHANGED
@@ -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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
data/lib/watir/clickJSDialog.rb
CHANGED
@@ -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
|
data/lib/watir/close_all.rb
CHANGED
@@ -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
|
data/lib/watir/collections.rb
CHANGED
@@ -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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
class
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
class
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
@
|
36
|
-
|
37
|
-
|
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
|
-
class
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
class
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
class
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
class
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
class
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
class
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
def
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
class
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
class
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
class
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
all
|
184
|
-
imgs
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
class
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
class
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
class
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
class
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
class
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
class
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
class
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
class
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
class
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
class
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
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
|