watir 1.6.5 → 1.6.6.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +461 -326
- data/VERSION +1 -0
- data/bin/watir-console +6 -6
- 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 -66
- data/lib/watir/clickJSDialog.rb +19 -19
- data/lib/watir/close_all.rb +37 -37
- data/lib/watir/collections.rb +392 -344
- data/lib/watir/container.rb +857 -815
- 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.rb +28 -0
- data/lib/watir/core_ext.rb +17 -17
- data/lib/watir/datahandler.rb +107 -107
- data/lib/watir/dialog.rb +46 -46
- data/lib/watir/element.rb +351 -343
- data/lib/watir/element_collections.rb +97 -97
- data/lib/watir/form.rb +170 -170
- data/lib/watir/frame.rb +59 -59
- data/lib/watir/html_element.rb +22 -0
- data/lib/watir/ie-class.rb +1006 -1009
- data/lib/watir/ie-process.rb +39 -39
- data/lib/watir/ie.rb +70 -133
- data/lib/watir/image.rb +130 -130
- data/lib/watir/input_elements.rb +614 -572
- data/lib/watir/irb-history.rb +30 -30
- data/lib/watir/link.rb +64 -64
- data/lib/watir/locator.rb +200 -176
- data/lib/watir/logger.rb +19 -19
- data/lib/watir/modal_dialog.rb +122 -122
- data/lib/watir/module.rb +37 -0
- data/lib/watir/non_control_elements.rb +145 -145
- data/lib/watir/page-container.rb +116 -107
- 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 +395 -362
- data/lib/watir/watir_simple.rb +475 -475
- data/lib/watir/win32.rb +35 -35
- data/lib/watir/win32ole.rb +14 -14
- data/lib/watir/winClicker.rb +496 -496
- data/rakefile.rb +70 -0
- data/unittests/all_tests.rb +10 -10
- data/unittests/buttons_xpath_test.rb +69 -69
- data/unittests/checkbox_test.rb +179 -179
- data/unittests/checkbox_xpath_test.rb +107 -107
- data/unittests/click_no_wait_test.rb +21 -0
- data/unittests/core_tests.rb +17 -17
- data/unittests/css_test.rb +42 -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 -188
- data/unittests/div_xpath_test.rb +96 -96
- data/unittests/element_test.rb +49 -0
- data/unittests/errorchecker_test.rb +32 -22
- data/unittests/filefield_test.rb +39 -39
- data/unittests/filefield_xpath_test.rb +33 -33
- data/unittests/form_test.rb +280 -280
- data/unittests/form_xpath_test.rb +252 -252
- data/unittests/frame_test.rb +155 -155
- 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/click_no_wait.html +14 -0
- data/unittests/html/complex_table.html +36 -36
- data/unittests/html/cssTest.html +42 -42
- data/unittests/html/depot_store.html +59 -59
- 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 +119 -119
- 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 -52
- 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/table_and_tablerow_to_a.html +174 -0
- 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 -51
- 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 -175
- data/unittests/links_xpath_test.rb +39 -39
- data/unittests/lists_test.rb +32 -32
- 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/other/jscriptExtraAlert.rb +6 -6
- data/unittests/other/jscriptExtraConfirmCancel.rb +6 -6
- data/unittests/other/jscriptExtraConfirmOk.rb +6 -6
- data/unittests/other/jscriptPushButton.rb +6 -6
- data/unittests/other/jscript_test.rb +63 -63
- data/unittests/other/navigate_exception_test.rb +24 -24
- data/unittests/other/rexml_unit_test.rb +27 -27
- 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 -148
- data/unittests/selectbox_xpath_test.rb +113 -113
- data/unittests/setup.rb +87 -77
- data/unittests/speed_settings_test.rb +67 -67
- data/unittests/table_and_tablerow_to_a_test.rb +117 -0
- data/unittests/table_cell_using_xpath_test.rb +35 -35
- data/unittests/table_test.rb +376 -376
- 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 -31
- data/unittests/textfields_test.rb +218 -218
- data/unittests/textfields_xpath_test.rb +111 -111
- data/unittests/window_tests.rb +10 -10
- data/unittests/windows/attach_to_existing_window_test.rb +53 -53
- data/unittests/windows/attach_to_new_window_test.rb +83 -83
- 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 +42 -55
- data/unittests/windows/modal_dialog_test.rb +128 -128
- data/unittests/windows/new_test.rb +57 -57
- data/unittests/windows/open_close_test.rb +18 -18
- data/unittests/windows/send_keys_test.rb +33 -33
- data/unittests/xpath_tests.rb +10 -10
- metadata +85 -31
- data/lib/watir/utils.rb +0 -20
- data/lib/watir/version.rb +0 -5
data/lib/watir/camel_case.rb
CHANGED
@@ -1,67 +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
|
-
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
|
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
|
67
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,344 +1,392 @@
|
|
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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
class
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
def
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
# this class accesses the
|
136
|
-
# Normally a user would not need to create this object as it is returned by the Watir::Container#
|
137
|
-
class
|
138
|
-
include CommonCollection
|
139
|
-
def element_class;
|
140
|
-
def element_tag; '
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
# this class accesses the
|
171
|
-
# Normally a user would not need to create this object as it is returned by the Watir::Container#
|
172
|
-
class
|
173
|
-
include CommonCollection
|
174
|
-
def element_class;
|
175
|
-
def element_tag; '
|
176
|
-
end
|
177
|
-
|
178
|
-
|
179
|
-
#
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
def
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
def
|
202
|
-
|
203
|
-
|
204
|
-
@
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
# this class accesses the
|
209
|
-
# Normally a user would not need to create this object as it is returned by the Watir::Container#
|
210
|
-
class
|
211
|
-
def element_class;
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
class
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
#
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
def
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
#
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
#
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
@show_attributes.
|
283
|
-
|
284
|
-
|
285
|
-
end
|
286
|
-
|
287
|
-
#
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
@show_attributes.
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
#
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
@show_attributes.
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
def
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
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 #:nodoc:all
|
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 #:nodoc:all
|
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
|
+
# number of buttons
|
72
|
+
# browser.buttons.length
|
73
|
+
def length
|
74
|
+
get_length_of_input_objects(["button", "submit", "image"])
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
def set_show_items
|
79
|
+
super
|
80
|
+
@show_attributes.add("disabled", 9)
|
81
|
+
@show_attributes.add("value", 20)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# this class accesses the file fields in the document as a collection
|
86
|
+
# normal access is via the Container#file_fields method
|
87
|
+
class FileFields < ElementCollections
|
88
|
+
def element_class; FileField; end
|
89
|
+
# number of file_fields
|
90
|
+
# browser.file_fields.length
|
91
|
+
def length
|
92
|
+
get_length_of_input_objects(["file"])
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
def set_show_items
|
97
|
+
super
|
98
|
+
@show_attributes.add("disabled", 9)
|
99
|
+
@show_attributes.add("value", 20)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# this class accesses the check boxes in the document as a collection
|
104
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#checkboxes method
|
105
|
+
class CheckBoxes < ElementCollections
|
106
|
+
def element_class; CheckBox; end
|
107
|
+
# number of checkboxes
|
108
|
+
# browser.checkboxes.length
|
109
|
+
def length
|
110
|
+
get_length_of_input_objects("checkbox")
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
def iterator_object(i)
|
115
|
+
@container.checkbox(:index, i + 1)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# this class accesses the radio buttons in the document as a collection
|
120
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#radios method
|
121
|
+
class Radios < ElementCollections
|
122
|
+
def element_class; Radio; end
|
123
|
+
# number of radios
|
124
|
+
# browser.radios.length
|
125
|
+
def length
|
126
|
+
get_length_of_input_objects("radio")
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
def iterator_object(i)
|
131
|
+
@container.radio(:index, i + 1)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# this class accesses the select boxes 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#select_lists method
|
137
|
+
class SelectLists < ElementCollections
|
138
|
+
include CommonCollection
|
139
|
+
def element_class; SelectList; end
|
140
|
+
def element_tag; 'SELECT'; end
|
141
|
+
end
|
142
|
+
|
143
|
+
# this class accesses the links in the document as a collection
|
144
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#links method
|
145
|
+
class Links < ElementCollections
|
146
|
+
include CommonCollection
|
147
|
+
def element_class; Link; end
|
148
|
+
def element_tag; 'A'; end
|
149
|
+
|
150
|
+
private
|
151
|
+
def set_show_items
|
152
|
+
super
|
153
|
+
@show_attributes.add("href", 60)
|
154
|
+
@show_attributes.add("innerText", 60)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
class Lis < ElementCollections
|
159
|
+
include CommonCollection
|
160
|
+
def element_class; Li; end
|
161
|
+
|
162
|
+
private
|
163
|
+
def set_show_items
|
164
|
+
super
|
165
|
+
@show_attributes.delete( "name")
|
166
|
+
@show_attributes.add( "className" , 20)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# this class accesses the maps 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#maps method
|
172
|
+
class Maps < ElementCollections
|
173
|
+
include CommonCollection
|
174
|
+
def element_class; Map; end
|
175
|
+
def element_tag; 'MAP'; end
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
# this class accesses the areas in the document as a collection
|
180
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#areas method
|
181
|
+
class Areas < ElementCollections
|
182
|
+
include CommonCollection
|
183
|
+
def element_class; Area; end
|
184
|
+
def element_tag; 'AREA'; end
|
185
|
+
end
|
186
|
+
|
187
|
+
# this class collects the images in the container
|
188
|
+
# An instance is returned by Watir::Container#images
|
189
|
+
class Images < ElementCollections
|
190
|
+
def element_class; Image; end
|
191
|
+
# number of images
|
192
|
+
# browser.images.length
|
193
|
+
def length
|
194
|
+
all = @container.document.all
|
195
|
+
imgs = []
|
196
|
+
all.each{|n| imgs << n if n.nodeName == "IMG"}
|
197
|
+
imgs.length
|
198
|
+
end
|
199
|
+
|
200
|
+
private
|
201
|
+
def set_show_items
|
202
|
+
super
|
203
|
+
@show_attributes.add("src", 60)
|
204
|
+
@show_attributes.add("alt", 30)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
# this class accesses the text 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#text_fields method
|
210
|
+
class TextFields < ElementCollections
|
211
|
+
def element_class; TextField; end
|
212
|
+
# number of text_fields
|
213
|
+
# browser.text_fields.length
|
214
|
+
def length
|
215
|
+
# text areas are also included in the TextFields, but we need to get them seperately
|
216
|
+
get_length_of_input_objects(["text", "password"]) +
|
217
|
+
@container.document.getElementsByTagName("textarea").length
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
# this class accesses the hidden fields in the document as a collection
|
222
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#hiddens method
|
223
|
+
class Hiddens < ElementCollections
|
224
|
+
def element_class; Hidden; end
|
225
|
+
# number of hidden elements
|
226
|
+
# browser.hiddens.length
|
227
|
+
def length
|
228
|
+
get_length_of_input_objects("hidden")
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
# this class accesses the text fields in the document as a collection
|
233
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#tables method
|
234
|
+
class Tables < ElementCollections
|
235
|
+
include CommonCollection
|
236
|
+
def element_class; Table; end
|
237
|
+
def element_tag; 'TABLE'; end
|
238
|
+
|
239
|
+
private
|
240
|
+
def set_show_items
|
241
|
+
super
|
242
|
+
@show_attributes.delete("name")
|
243
|
+
end
|
244
|
+
end
|
245
|
+
# this class accesses the table rows in the document as a collection
|
246
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#rows method
|
247
|
+
class TableRows < ElementCollections
|
248
|
+
include CommonCollection
|
249
|
+
def element_class; TableRow; end
|
250
|
+
def element_tag; 'TR'; end
|
251
|
+
end
|
252
|
+
# this class accesses the table cells in the document as a collection
|
253
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#cells method
|
254
|
+
class TableCells < ElementCollections
|
255
|
+
include CommonCollection
|
256
|
+
def element_class; TableCell; end
|
257
|
+
def element_tag; 'TD'; end
|
258
|
+
end
|
259
|
+
# this class accesses the labels in the document as a collection
|
260
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#labels method
|
261
|
+
class Labels < ElementCollections
|
262
|
+
include CommonCollection
|
263
|
+
def element_class; Label; end
|
264
|
+
def element_tag; 'LABEL'; end
|
265
|
+
|
266
|
+
private
|
267
|
+
def set_show_items
|
268
|
+
super
|
269
|
+
@show_attributes.add("htmlFor", 20)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
# this class accesses the pre tags in the document as a collection
|
274
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#pres method
|
275
|
+
class Pres < ElementCollections
|
276
|
+
include CommonCollection
|
277
|
+
def element_class; Pre; end
|
278
|
+
|
279
|
+
private
|
280
|
+
def set_show_items
|
281
|
+
super
|
282
|
+
@show_attributes.delete("name")
|
283
|
+
@show_attributes.add("className", 20)
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
# this class accesses the p tags in the document as a collection
|
288
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#ps method
|
289
|
+
class Ps < ElementCollections
|
290
|
+
include CommonCollection
|
291
|
+
def element_class; P; end
|
292
|
+
|
293
|
+
private
|
294
|
+
def set_show_items
|
295
|
+
super
|
296
|
+
@show_attributes.delete("name")
|
297
|
+
@show_attributes.add("className", 20)
|
298
|
+
end
|
299
|
+
|
300
|
+
end
|
301
|
+
# this class accesses the spans in the document as a collection
|
302
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#spans method
|
303
|
+
class Spans < ElementCollections
|
304
|
+
include CommonCollection
|
305
|
+
def element_class; Span; end
|
306
|
+
|
307
|
+
private
|
308
|
+
def set_show_items
|
309
|
+
super
|
310
|
+
@show_attributes.delete("name")
|
311
|
+
@show_attributes.add("className", 20)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
# this class accesses the divs in the document as a collection
|
316
|
+
# Normally a user would not need to create this object as it is returned by the Watir::Container#divs method
|
317
|
+
class Divs < ElementCollections
|
318
|
+
include CommonCollection
|
319
|
+
def element_class; Div; end
|
320
|
+
|
321
|
+
private
|
322
|
+
def set_show_items
|
323
|
+
super
|
324
|
+
@show_attributes.delete("name")
|
325
|
+
@show_attributes.add("className", 20)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
class Dls < ElementCollections
|
330
|
+
include CommonCollection
|
331
|
+
def element_class; Dl; end
|
332
|
+
def element_tag; Dl::TAG; end
|
333
|
+
end
|
334
|
+
|
335
|
+
class Dts < ElementCollections
|
336
|
+
include CommonCollection
|
337
|
+
def element_class; Dt; end
|
338
|
+
def element_tag; Dt::TAG; end
|
339
|
+
end
|
340
|
+
|
341
|
+
class Dds < ElementCollections
|
342
|
+
include CommonCollection
|
343
|
+
def element_class; Dd; end
|
344
|
+
def element_tag; Dd::TAG; end
|
345
|
+
end
|
346
|
+
|
347
|
+
class Strongs < ElementCollections
|
348
|
+
include CommonCollection
|
349
|
+
def element_class; Strong; end
|
350
|
+
def element_tag; Strong::TAG; end
|
351
|
+
end
|
352
|
+
|
353
|
+
class Ems < ElementCollections
|
354
|
+
include CommonCollection
|
355
|
+
def element_class; Em; end
|
356
|
+
def element_tag; Em::TAG; end
|
357
|
+
end
|
358
|
+
|
359
|
+
class HTMLElements < ElementCollections
|
360
|
+
include CommonCollection
|
361
|
+
def element_class; HTMLElement; end
|
362
|
+
def element_tag; '*'; end
|
363
|
+
|
364
|
+
def initialize(container, how, what)
|
365
|
+
@how = how
|
366
|
+
@what = what
|
367
|
+
if how == :index
|
368
|
+
raise MissingWayOfFindingObjectException,
|
369
|
+
"#{self.class} does not support attribute #{@how}"
|
370
|
+
end
|
371
|
+
super(container)
|
372
|
+
end
|
373
|
+
|
374
|
+
def length
|
375
|
+
count = 0
|
376
|
+
each {|element| count += 1 }
|
377
|
+
count
|
378
|
+
end
|
379
|
+
alias :size :length
|
380
|
+
|
381
|
+
def each
|
382
|
+
@container.locate_all_elements(@how, @what).each { |element| yield element }
|
383
|
+
end
|
384
|
+
|
385
|
+
def iterator_object(i)
|
386
|
+
count = 0
|
387
|
+
each {|e| return e if count == i;count += 1;}
|
388
|
+
end
|
389
|
+
|
390
|
+
end
|
391
|
+
|
392
|
+
end
|