watir 1.4.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/watir-console +1 -0
- data/changes.rb +119 -0
- data/license.rb +37 -0
- data/readme.rb +55 -120
- data/unittests/buttons_test.rb +107 -104
- data/unittests/buttons_xpath_test.rb +69 -0
- data/unittests/checkbox_test.rb +154 -141
- data/unittests/checkbox_xpath_test.rb +107 -0
- data/unittests/core_tests.rb +6 -2
- data/unittests/css_test.rb +50 -50
- data/unittests/defer_test.rb +47 -0
- data/unittests/dialog_test.rb +78 -0
- data/unittests/div2_xpath_test.rb +22 -0
- data/unittests/div_test.rb +159 -159
- data/unittests/div_xpath_test.rb +96 -0
- data/unittests/errorchecker_test.rb +22 -22
- data/unittests/filefield_test.rb +30 -23
- data/unittests/filefield_xpath_test.rb +35 -0
- data/unittests/form_test.rb +250 -229
- data/unittests/form_xpath_test.rb +253 -0
- data/unittests/frame_test.rb +123 -108
- data/unittests/google_form_test.rb +17 -0
- data/unittests/html/JavascriptClick.html +39 -0
- data/unittests/html/buttons1.html +3 -2
- data/unittests/html/checkboxes1.html +32 -14
- data/unittests/html/complex_table.html +1 -1
- data/unittests/html/depot_store.html +59 -0
- data/unittests/html/div.html +3 -21
- data/unittests/html/div_xml.html +21 -0
- data/unittests/html/fileupload.html +2 -2
- data/unittests/html/forms2.html +3 -3
- data/unittests/html/forms3.html +2 -2
- data/unittests/html/frame_links.html +2 -2
- data/unittests/html/google_india.html +119 -0
- data/unittests/html/iframeTest.html +2 -2
- data/unittests/html/images/map.GIF +0 -0
- data/unittests/html/images/map2.gif +0 -0
- data/unittests/html/images1.html +17 -2
- data/unittests/html/javascriptevents.html +3 -7
- data/unittests/html/links1.html +9 -8
- data/unittests/html/links_multi.html +14 -0
- data/unittests/html/list_matters.html +720 -0
- data/unittests/html/lists.html +18 -0
- data/unittests/html/map_test.html +31 -0
- data/unittests/html/modal_dialog.html +10 -0
- data/unittests/html/modal_dialog_launcher.html +12 -0
- data/unittests/html/new_browser.html +17 -0
- data/unittests/html/pass.html +3 -0
- data/unittests/html/popups1.html +1 -1
- data/unittests/html/pre.html +28 -0
- data/unittests/html/radioButtons1.html +6 -5
- data/unittests/html/selectboxes1.html +12 -11
- data/unittests/html/simple_table.html +1 -1
- data/unittests/html/simple_table_columns.html +1 -1
- data/unittests/html/table1.html +1 -1
- data/unittests/html/tableCell_using_xpath.html +19 -0
- data/unittests/html/textfields1.html +6 -4
- data/unittests/html/xpath_nbsp.html +12 -0
- data/unittests/ie_exists_test.rb +32 -0
- data/unittests/ie_mock.rb +78 -79
- data/unittests/ie_test.rb +39 -39
- data/unittests/images_test.rb +132 -155
- data/unittests/images_xpath_test.rb +91 -0
- data/unittests/links_multi_test.rb +36 -0
- data/unittests/links_test.rb +158 -152
- data/unittests/links_xpath_test.rb +40 -0
- data/unittests/lists_test.rb +29 -0
- data/unittests/map_test.rb +99 -0
- data/unittests/minmax_test.rb +23 -23
- data/unittests/navigate_test.rb +43 -51
- data/unittests/nbsp_xpath_test.rb +18 -0
- data/unittests/other/WindowLogonExample.rb +28 -0
- data/unittests/{WindowLogonExtra.rb → other/WindowLogonExtra.rb} +0 -0
- data/unittests/{all_tests_concurrent.rb → other/all_tests_concurrent.rb} +23 -23
- data/unittests/other/navigate_exception_test.rb +14 -0
- data/unittests/other/rexml_unit_test.rb +24 -0
- data/unittests/other/testcase_method_order_test.rb +36 -0
- data/unittests/other/testcase_verify_test.rb +25 -0
- data/unittests/other/wait_until_test.rb +99 -0
- data/unittests/pagecontainstext_test.rb +56 -37
- data/unittests/parent_child_test.rb +55 -0
- data/unittests/popups_test.rb +37 -37
- data/unittests/pre_test.rb +52 -0
- data/unittests/radios_test.rb +186 -155
- data/unittests/radios_xpath_test.rb +101 -0
- data/unittests/screen_capture_test.rb +41 -41
- data/unittests/selectbox_test.rb +223 -181
- data/unittests/selectbox_xpath_test.rb +113 -0
- data/unittests/setup.rb +29 -25
- data/unittests/speed_settings_test.rb +22 -0
- data/unittests/table_cell_using_xpath_test.rb +40 -0
- data/unittests/table_test.rb +315 -284
- data/unittests/table_xpath_test.rb +114 -0
- data/unittests/textarea_test.rb +81 -0
- data/unittests/textarea_xpath_test.rb +82 -0
- data/unittests/textfields_test.rb +205 -229
- data/unittests/textfields_xpath_test.rb +111 -0
- data/unittests/window_tests.rb +7 -0
- data/unittests/windows/attach_to_existing_window_test.rb +52 -0
- data/unittests/windows/attach_to_new_window_test.rb +82 -0
- data/unittests/windows/close_window_test.rb +22 -0
- data/unittests/windows/frame_links_test.rb +25 -0
- data/unittests/windows/ie-each_test.rb +48 -0
- data/unittests/windows/iedialog_test.rb +55 -0
- data/unittests/windows/js_events_test.rb +57 -0
- data/unittests/windows/jscriptExtraAlert.rb +6 -0
- data/unittests/windows/jscriptExtraConfirmCancel.rb +7 -0
- data/unittests/windows/jscriptExtraConfirmOk.rb +7 -0
- data/unittests/{jscriptPushButton.rb → windows/jscriptPushButton.rb} +1 -1
- data/unittests/windows/jscript_test.rb +64 -0
- data/unittests/windows/modal_dialog_test.rb +127 -0
- data/unittests/windows/new.rb +56 -0
- data/unittests/windows/open_close_test.rb +22 -0
- data/unittests/windows/send_keys_test.rb +34 -0
- data/unittests/xpath_tests.rb +10 -0
- data/watir.rb +4344 -3565
- data/watir/IEDialog/Release/IEDialog.dll +0 -0
- data/watir/WindowHelper.rb +13 -11
- data/watir/assertions.rb +36 -0
- data/watir/camel_case.rb +14 -5
- data/watir/close_all.rb +38 -0
- data/watir/contrib/enabled_popup.rb +21 -0
- data/watir/contrib/ie-new-process.rb +27 -0
- data/watir/contrib/page_checker.rb +29 -0
- data/watir/contrib/visible.rb +47 -0
- data/watir/cookiemanager.rb +4 -4
- data/watir/datahandler.rb +107 -0
- data/watir/dialog.rb +46 -0
- data/watir/elements.rb +65 -0
- data/watir/exceptions.rb +18 -36
- data/watir/ie-process.rb +40 -0
- data/watir/irb-history.rb +31 -0
- data/watir/process.rb +20 -0
- data/watir/testUnitAddons.rb +3 -42
- data/watir/testcase.rb +58 -0
- data/watir/utils.rb +20 -0
- data/watir/waiter.rb +88 -0
- data/watir/watir_simple.rb +4 -4
- data/watir/win32ole.rb +8 -0
- data/watir/win32ole/win32ole.so +0 -0
- data/watir/winClicker.rb +374 -400
- metadata +209 -128
- data/unittests/WindowLogonExample.rb +0 -30
- data/unittests/attachToExistingWindow_test.rb +0 -40
- data/unittests/js_events_test.rb +0 -77
- data/unittests/jscriptExtraAlert.rb +0 -6
- data/unittests/jscriptExtraConfirmCancel.rb +0 -7
- data/unittests/jscriptExtraConfirmOk.rb +0 -7
- data/unittests/jscript_test.rb +0 -57
- data/unittests/send_keys_test.rb +0 -29
- data/unittests/textAreafields_test.rb +0 -81
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# feature tests for Radio Buttons
|
|
2
|
+
# revision: $Revision: 962 $
|
|
3
|
+
|
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
|
5
|
+
require 'unittests/setup'
|
|
6
|
+
|
|
7
|
+
class TC_Radios_XPath < Test::Unit::TestCase
|
|
8
|
+
include Watir
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
$ie.goto($htmlRoot + "radioButtons1.html")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_Radio_Exists
|
|
15
|
+
assert($ie.radio(:xpath, "//input[@name='box1']/").exists?)
|
|
16
|
+
assert($ie.radio(:xpath, "//input[@id='box5']/").exists?)
|
|
17
|
+
|
|
18
|
+
assert(!$ie.radio(:xpath, "//input[@name='missingname']/").exists?)
|
|
19
|
+
assert(!$ie.radio(:xpath, "//input[@id='missingid']/").exists?)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_Radio_Enabled
|
|
23
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").enabled? }
|
|
24
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@id='noName']/").enabled? }
|
|
25
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='box4' and @value='6']/").enabled? }
|
|
26
|
+
|
|
27
|
+
assert(!$ie.radio(:xpath, "//input[@name='box2']/").enabled?)
|
|
28
|
+
assert($ie.radio(:xpath, "//input[@id='box5']/").enabled?)
|
|
29
|
+
assert($ie.radio(:xpath, "//input[@name='box1']/").enabled?)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_little
|
|
33
|
+
assert(!$ie.button(:xpath,"//input[@name='foo']/").enabled?)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_onClick
|
|
37
|
+
assert(!$ie.button(:xpath,"//input[@name='foo']/").enabled?)
|
|
38
|
+
$ie.radio(:xpath, "//input[@name='box5' and @value='1']/").set
|
|
39
|
+
assert($ie.button(:xpath,"//input[@name='foo']/").enabled?)
|
|
40
|
+
|
|
41
|
+
$ie.radio(:xpath, "//input[@name='box5' and @value='2']/").set
|
|
42
|
+
assert(!$ie.button(:xpath,"//input[@name='foo']/").enabled?)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_Radio_isSet
|
|
46
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").isSet? }
|
|
47
|
+
|
|
48
|
+
puts "radio 1 is set : #{ $ie.radio(:xpath, "//input[@name='box1']/").isSet? } "
|
|
49
|
+
assert(!$ie.radio(:xpath, "//input[@name='box1']/").isSet?)
|
|
50
|
+
|
|
51
|
+
assert($ie.radio(:xpath, "//input[@name='box3']/").isSet?)
|
|
52
|
+
assert(!$ie.radio(:xpath, "//input[@name='box2']/").isSet?)
|
|
53
|
+
|
|
54
|
+
assert( $ie.radio(:xpath, "//input[@name='box4' and @value='1']/").isSet?)
|
|
55
|
+
assert(!$ie.radio(:xpath, "//input[@name='box4' and @value='2']/").isSet?)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_radio_clear
|
|
59
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").clear }
|
|
60
|
+
|
|
61
|
+
$ie.radio(:xpath, "//input[@name='box1']/").clear
|
|
62
|
+
assert(!$ie.radio(:xpath, "//input[@name='box1']/").isSet?)
|
|
63
|
+
|
|
64
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='box2']/").clear }
|
|
65
|
+
assert(!$ie.radio(:xpath, "//input[@name='box2']/").isSet?)
|
|
66
|
+
|
|
67
|
+
$ie.radio(:xpath, "//input[@name='box3']/").clear
|
|
68
|
+
assert(!$ie.radio(:xpath, "//input[@name='box3']/").isSet?)
|
|
69
|
+
|
|
70
|
+
$ie.radio(:xpath, "//input[@name='box4' and @value='1']/").clear
|
|
71
|
+
assert(!$ie.radio(:xpath, "//input[@name='box4' and @value='1']/").isSet?)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_radio_getState
|
|
75
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").getState }
|
|
76
|
+
|
|
77
|
+
assert_equal( false , $ie.radio(:xpath, "//input[@name='box1']/").getState )
|
|
78
|
+
assert_equal( true , $ie.radio(:xpath, "//input[@name='box3']/").getState)
|
|
79
|
+
|
|
80
|
+
# radioes that have the same name but different values
|
|
81
|
+
assert_equal( false , $ie.radio(:xpath, "//input[@name='box4' and @value='2']/").getState )
|
|
82
|
+
assert_equal( true , $ie.radio(:xpath, "//input[@name='box4' and @value='1']/").getState)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_radio_set
|
|
86
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").set }
|
|
87
|
+
$ie.radio(:xpath, "//input[@name='box1']/").set
|
|
88
|
+
assert($ie.radio(:xpath, "//input[@name='box1']/").isSet?)
|
|
89
|
+
|
|
90
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='box2']/").set }
|
|
91
|
+
|
|
92
|
+
$ie.radio(:xpath, "//input[@name='box3']/").set
|
|
93
|
+
assert($ie.radio(:xpath, "//input[@name='box3']/").isSet?)
|
|
94
|
+
|
|
95
|
+
# radioes that have the same name but different values
|
|
96
|
+
$ie.radio(:xpath, "//input[@name='box4' and @value='3']/").set
|
|
97
|
+
assert($ie.radio(:xpath, "//input[@name='box4' and @value='3']/").isSet?)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|
|
101
|
+
|
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
# feature tests for screen capture
|
|
2
|
-
# revision: $Revision:
|
|
2
|
+
# revision: $Revision: 958 $
|
|
3
3
|
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
|
5
5
|
require 'unittests/setup'
|
|
6
6
|
require 'watir/screen_capture'
|
|
7
7
|
|
|
8
8
|
class TC_Capture< Test::Unit::TestCase
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
include Watir
|
|
10
|
+
include Watir::ScreenCapture
|
|
11
|
+
|
|
12
|
+
def setup
|
|
13
|
+
delete_captured_files( [ 'jpeg1.jpg' , 'jpeg2.jpg' , 'bmp1.bmp', 'bmp2.bmp' ] )
|
|
14
|
+
$ie.goto($htmlRoot + 'buttons1.html' )
|
|
15
|
+
@file_list = []
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def teardown
|
|
19
|
+
delete_captured_files
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def delete_captured_files(files=nil )
|
|
23
|
+
files = @file_list unless files
|
|
24
|
+
files.each do |f|
|
|
25
|
+
File.delete( f) if FileTest.exists?( f)
|
|
20
26
|
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_jpeg
|
|
30
|
+
file_name= 'jpeg1.jpg'
|
|
31
|
+
@file_list << file_name
|
|
32
|
+
screen_capture( file_name )
|
|
33
|
+
assert(FileTest.exist?( file_name) )
|
|
21
34
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
file_name= 'jpeg2.jpg'
|
|
36
|
+
@file_list << file_name
|
|
37
|
+
screen_capture( file_name , true ) # just the active window
|
|
38
|
+
assert(FileTest.exist?( file_name) )
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_bmp
|
|
42
|
+
file_name= 'bmp1.bmp'
|
|
43
|
+
@file_list << file_name
|
|
44
|
+
screen_capture( file_name , false, true )
|
|
45
|
+
assert(FileTest.exist?( file_name ) )
|
|
28
46
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
file_name= 'jpeg2.jpg'
|
|
36
|
-
@file_list << file_name
|
|
37
|
-
screen_capture( file_name , true ) # just the active window
|
|
38
|
-
assert(FileTest.exist?( file_name) )
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def test_bmp
|
|
42
|
-
file_name= 'bmp1.bmp'
|
|
43
|
-
@file_list << file_name
|
|
44
|
-
screen_capture( file_name , false, true )
|
|
45
|
-
assert(FileTest.exist?( file_name ) )
|
|
46
|
-
|
|
47
|
-
file_name= 'bmp2.bmp'
|
|
48
|
-
@file_list << file_name
|
|
49
|
-
screen_capture( file_name , true , true ) # just the active window
|
|
50
|
-
assert(FileTest.exist?( file_name) )
|
|
51
|
-
end
|
|
47
|
+
file_name= 'bmp2.bmp'
|
|
48
|
+
@file_list << file_name
|
|
49
|
+
screen_capture( file_name , true , true ) # just the active window
|
|
50
|
+
assert(FileTest.exist?( file_name) )
|
|
51
|
+
end
|
|
52
52
|
end
|
|
53
53
|
|
data/unittests/selectbox_test.rb
CHANGED
|
@@ -1,197 +1,239 @@
|
|
|
1
1
|
# feature tests for Select Boxes
|
|
2
|
-
# revision: $Revision:
|
|
2
|
+
# revision: $Revision: 1111 $
|
|
3
3
|
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
|
5
5
|
require 'unittests/setup'
|
|
6
6
|
|
|
7
7
|
class TC_SelectList < Test::Unit::TestCase
|
|
8
|
-
|
|
8
|
+
include Watir
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
$ie.goto($htmlRoot + "selectboxes1.html")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_SelectList_exists
|
|
15
|
+
assert($ie.select_list(:name, "sel1").exists?)
|
|
16
|
+
assert(!$ie.select_list(:name, "missing").exists?)
|
|
17
|
+
assert(!$ie.select_list(:id, "missing").exists?)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_SelectList_enabled
|
|
21
|
+
assert($ie.select_list(:name, "sel1").enabled?)
|
|
22
|
+
assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").enabled? }
|
|
23
|
+
assert(!$ie.select_list(:id, 'selectbox_4').enabled?)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_SelectList_class_name
|
|
27
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:name, "missing").class_name }
|
|
28
|
+
assert_equal("list_style" , $ie.select_list(:name, "sel1").class_name)
|
|
29
|
+
assert_equal("" , $ie.selectBox(:name, "sel2").class_name )
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_Option_text_select
|
|
35
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, "missing item").select }
|
|
36
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, /missing/).select }
|
|
37
|
+
assert_raises(MissingWayOfFindingObjectException) { $ie.select_list(:name, "sel1").option(:missing, "Option 1").select }
|
|
38
|
+
|
|
39
|
+
# the select method keeps any currently selected items - use the clear selection method first
|
|
40
|
+
$ie.select_list( :name , "sel1").clearSelection
|
|
41
|
+
$ie.select_list( :name , "sel1").option(:text, "Option 1").select
|
|
42
|
+
assert_equal( ["Option 1" ] , $ie.select_list(:name, "sel1").getSelectedItems)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def xtest_option_class_name
|
|
47
|
+
|
|
48
|
+
# the option object doesnt inherit from element, so this doesnt work
|
|
49
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, "missing item").class_name }
|
|
50
|
+
assert_equal("list_style" , $ie.select_list(:name, "sel2").option(:value , 'o2').class_name)
|
|
51
|
+
assert_equal("" , $ie.select_list(:name, "sel2").option(:value , 'o1').class_name)
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_includes
|
|
56
|
+
assert $ie.select_list(:name, 'sel1').includes?('Option 1')
|
|
57
|
+
assert ! $ie.select_list(:name, 'sel1').includes?('Option 6')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_selected
|
|
61
|
+
assert ! $ie.select_list(:name, 'sel1').selected?('Option 1')
|
|
62
|
+
assert $ie.select_list(:name, 'sel1').selected?('Option 3')
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_selected_not_found
|
|
66
|
+
selectbox = $ie.select_list(:name, 'sel1')
|
|
67
|
+
assert_raises(Watir::Exception::UnknownObjectException) {selectbox.selected?('Option Not Exists')}
|
|
68
|
+
end
|
|
9
69
|
|
|
10
|
-
def setup()
|
|
11
|
-
$ie.goto($htmlRoot + "selectboxes1.html")
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def test_SelectList_exists
|
|
15
|
-
assert($ie.select_list(:name, "sel1").exists?)
|
|
16
|
-
assert_false($ie.select_list(:name, "missing").exists?)
|
|
17
|
-
assert_false($ie.select_list(:id, "missing").exists?)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_SelectList_enabled
|
|
21
|
-
assert($ie.select_list(:name, "sel1").enabled?)
|
|
22
|
-
assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").enabled? }
|
|
23
|
-
assert_false($ie.select_list(:id, 'selectbox_4').enabled?)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_Option_text_select
|
|
27
|
-
assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, "missing item").select }
|
|
28
|
-
assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, /missing/).select }
|
|
29
|
-
assert_raises(MissingWayOfFindingObjectException) { $ie.select_list(:name, "sel1").option(:missing, "Option 1").select }
|
|
30
|
-
|
|
31
|
-
# the select method keeps any currently selected items - use the clear selection method first
|
|
32
|
-
$ie.select_list( :name , "sel1").clearSelection
|
|
33
|
-
$ie.select_list( :name , "sel1").option(:text, "Option 1").select
|
|
34
|
-
assert_arrayEquals( ["Option 1" ] , $ie.select_list(:name, "sel1").getSelectedItems)
|
|
35
|
-
end
|
|
36
70
|
end
|
|
37
71
|
|
|
38
72
|
# Tests for the old interface
|
|
39
73
|
class TC_Selectbox < Test::Unit::TestCase
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
74
|
+
include Watir
|
|
75
|
+
|
|
76
|
+
def setup
|
|
77
|
+
$ie.goto($htmlRoot + "selectboxes1.html")
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_selectBox_Exists
|
|
81
|
+
assert($ie.selectBox(:name, "sel1").exists?)
|
|
82
|
+
assert(!$ie.selectBox(:name, "missing").exists?)
|
|
83
|
+
assert(!$ie.selectBox(:id, "missing").exists?)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def test_selectBox_enabled
|
|
87
|
+
assert($ie.selectBox(:name, "sel1").enabled?)
|
|
88
|
+
assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").enabled? }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_SelectList_class_name
|
|
93
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:name, "missing").class_name }
|
|
94
|
+
assert_equal("list_style" , $ie.select_list(:name, "sel1").class_name)
|
|
95
|
+
assert_equal("" , $ie.selectBox(:name, "sel2").class_name )
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def test_selectBox_getAllContents
|
|
100
|
+
assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").getAllContents }
|
|
101
|
+
assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
|
|
102
|
+
$ie.selectBox(:name, "sel1").getAllContents)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def test_selectBox_getSelectedItems
|
|
106
|
+
assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").getSelectedItems }
|
|
107
|
+
assert_equal( ["Option 3" ] ,
|
|
108
|
+
$ie.selectBox(:name, "sel1").getSelectedItems)
|
|
109
|
+
assert_equal( ["Option 3" , "Option 6" ] ,
|
|
110
|
+
$ie.selectBox(:name, "sel2").getSelectedItems)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def test_clearSelection
|
|
114
|
+
assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").clearSelection }
|
|
115
|
+
$ie.selectBox( :name , "sel1").clearSelection
|
|
116
|
+
|
|
117
|
+
# the box sel1 has no ability to have a de-selected item
|
|
118
|
+
assert_equal( ["Option 3" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
|
|
119
|
+
|
|
120
|
+
$ie.selectBox( :name , "sel2").clearSelection
|
|
121
|
+
assert_equal( [ ] , $ie.selectBox(:name, "sel2").getSelectedItems)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def test_selectBox_select
|
|
125
|
+
assert_raises(NoValueFoundException) { $ie.selectBox(:name, "sel1").select("missing item") }
|
|
126
|
+
assert_raises(NoValueFoundException) { $ie.selectBox(:name, "sel1").select(/missing/) }
|
|
127
|
+
|
|
128
|
+
# the select method keeps any currently selected items - use the clear selectcion method first
|
|
129
|
+
$ie.selectBox( :name , "sel1").clearSelection
|
|
130
|
+
$ie.selectBox( :name , "sel1").select("Option 1")
|
|
131
|
+
assert_equal( ["Option 1" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
|
|
132
|
+
|
|
133
|
+
$ie.selectBox( :name , "sel1").clearSelection
|
|
134
|
+
$ie.selectBox( :name , "sel1").select(/2/)
|
|
135
|
+
assert_equal( ["Option 2" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
|
|
136
|
+
|
|
137
|
+
$ie.selectBox( :name , "sel2").clearSelection
|
|
138
|
+
$ie.selectBox( :name , "sel2").select(/2/)
|
|
139
|
+
$ie.selectBox( :name , "sel2").select(/4/)
|
|
140
|
+
assert_equal( ["Option 2" , "Option 4" ] ,
|
|
141
|
+
$ie.selectBox(:name, "sel2").getSelectedItems)
|
|
142
|
+
|
|
143
|
+
# these are to test the onchange event
|
|
144
|
+
# the event shouldnt get fired, as this is the selected item
|
|
145
|
+
$ie.selectBox( :name , "sel3").select( /3/ )
|
|
146
|
+
assert(!$ie.text.include?("Pass") )
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_selectBox_select2
|
|
150
|
+
# the event should get fired
|
|
151
|
+
$ie.selectBox( :name , "sel3").select( /2/ )
|
|
152
|
+
assert($ie.text.include?("PASS") )
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def test_selectBox_select_using_value
|
|
156
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:name, "NoName").getSelectedItems }
|
|
157
|
+
assert_raises(NoValueFoundException) { $ie.select_list(:name, "sel1").select_value("missing item") }
|
|
158
|
+
assert_raises(NoValueFoundException) { $ie.select_list(:name, "sel1").select_value(/missing/) }
|
|
159
|
+
|
|
160
|
+
# the select method keeps any currently selected items - use the clear selectcion method first
|
|
161
|
+
$ie.select_list( :name , "sel1").clearSelection
|
|
162
|
+
$ie.select_list( :name , "sel1").select_value("o1")
|
|
163
|
+
assert_equal( ["Option 1" ] , $ie.select_list(:name, "sel1").getSelectedItems)
|
|
164
|
+
|
|
165
|
+
$ie.select_list( :name , "sel1").clearSelection
|
|
166
|
+
$ie.select_list( :name , "sel1").select_value(/2/)
|
|
167
|
+
assert_equal( ["Option 2" ] , $ie.select_list(:name, "sel1").getSelectedItems)
|
|
168
|
+
|
|
169
|
+
$ie.select_list( :name , "sel2").clearSelection
|
|
170
|
+
$ie.select_list( :name , "sel2").select_value(/4/)
|
|
171
|
+
$ie.select_list( :name , "sel2").select_value(/2/)
|
|
172
|
+
assert_equal( ["Option 2" , "Option 4" ] ,
|
|
173
|
+
$ie.select_list(:name, "sel2").getSelectedItems)
|
|
174
|
+
|
|
175
|
+
# these are to test the onchange event
|
|
176
|
+
# the event shouldnt get fired, as this is the selected item
|
|
177
|
+
$ie.select_list( :name , "sel3").select_value( /3/ )
|
|
178
|
+
assert(!$ie.text.include?("Pass") )
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def test_select_list_select_using_value2
|
|
182
|
+
# the event should get fired
|
|
183
|
+
$ie.select_list( :name , "sel3").select_value( /2/ )
|
|
184
|
+
assert($ie.text.include?("PASS") )
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def test_select_list_properties
|
|
188
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).value }
|
|
189
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).name }
|
|
190
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).id }
|
|
191
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).disabled }
|
|
192
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).type }
|
|
193
|
+
|
|
194
|
+
assert_equal("o3" , $ie.select_list(:index, 1).value)
|
|
195
|
+
assert_equal("sel1" , $ie.select_list(:index, 1).name )
|
|
196
|
+
assert_equal("" , $ie.select_list(:index, 1).id )
|
|
197
|
+
assert_equal("select-one", $ie.select_list(:index, 1).type )
|
|
198
|
+
assert_equal("select-multiple", $ie.select_list(:index, 2).type )
|
|
199
|
+
|
|
200
|
+
$ie.select_list(:index,1).select(/1/)
|
|
201
|
+
assert_equal("o1" , $ie.select_list(:index, 1).value)
|
|
202
|
+
|
|
203
|
+
assert(! $ie.select_list(:index, 1).disabled )
|
|
204
|
+
assert( $ie.select_list(:index, 4).disabled )
|
|
205
|
+
assert( $ie.select_list(:id, 'selectbox_4').disabled )
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def test_select_list_iterator
|
|
209
|
+
assert_equal(4, $ie.select_lists.length)
|
|
210
|
+
assert_equal("o3" , $ie.select_lists[1].value)
|
|
211
|
+
assert_equal("sel1" , $ie.select_lists[1].name )
|
|
212
|
+
assert_equal("select-one", $ie.select_lists[1].type )
|
|
213
|
+
assert_equal("select-multiple" , $ie.select_lists[2].type )
|
|
214
|
+
|
|
215
|
+
index=1
|
|
216
|
+
$ie.select_lists.each do |l|
|
|
217
|
+
assert_equal( $ie.select_list(:index, index).name , l.name )
|
|
218
|
+
assert_equal( $ie.select_list(:index, index).id , l.id )
|
|
219
|
+
assert_equal( $ie.select_list(:index, index).type , l.type )
|
|
220
|
+
assert_equal( $ie.select_list(:index, index).value , l.value )
|
|
221
|
+
index+=1
|
|
222
|
+
end
|
|
223
|
+
assert_equal( index-1, $ie.select_lists.length)
|
|
224
|
+
end
|
|
183
225
|
end
|
|
184
226
|
|
|
185
227
|
class TC_Select_Options < Test::Unit::TestCase
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
228
|
+
include Watir
|
|
229
|
+
|
|
230
|
+
def setup
|
|
231
|
+
$ie.goto($htmlRoot + "select_tealeaf.html")
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def test_options_text
|
|
235
|
+
$ie.select_list(:name, 'op_numhits').option(:text, '>=').select
|
|
236
|
+
assert($ie.select_list(:name, 'op_numhits').option(:text, '>=').selected)
|
|
237
|
+
end
|
|
196
238
|
end
|
|
197
239
|
|