watir-classic 3.0.0
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/CHANGES +721 -0
- data/LICENSE +34 -0
- data/README.rdoc +78 -0
- data/VERSION +1 -0
- data/bin/watir-console +5 -0
- data/lib/watir-classic.rb +14 -0
- data/lib/watir-classic/IEDialog/Release/IEDialog.dll +0 -0
- data/lib/watir-classic/assertions.rb +44 -0
- data/lib/watir-classic/browser.rb +149 -0
- data/lib/watir-classic/browsers.rb +7 -0
- data/lib/watir-classic/close_all.rb +31 -0
- data/lib/watir-classic/container.rb +110 -0
- data/lib/watir-classic/contrib/enabled_popup.rb +21 -0
- data/lib/watir-classic/contrib/ie-new-process.rb +27 -0
- data/lib/watir-classic/contrib/page_checker.rb +29 -0
- data/lib/watir-classic/cookies.rb +80 -0
- data/lib/watir-classic/core.rb +43 -0
- data/lib/watir-classic/dialogs/file_field.rb +34 -0
- data/lib/watir-classic/dialogs/javascript.rb +43 -0
- data/lib/watir-classic/drag_and_drop_helper.rb +68 -0
- data/lib/watir-classic/element.rb +438 -0
- data/lib/watir-classic/element_collection.rb +109 -0
- data/lib/watir-classic/element_extensions.rb +69 -0
- data/lib/watir-classic/exceptions.rb +50 -0
- data/lib/watir-classic/form.rb +96 -0
- data/lib/watir-classic/frame.rb +47 -0
- data/lib/watir-classic/ie-class.rb +767 -0
- data/lib/watir-classic/ie-process.rb +47 -0
- data/lib/watir-classic/ie.rb +20 -0
- data/lib/watir-classic/image.rb +111 -0
- data/lib/watir-classic/input_elements.rb +480 -0
- data/lib/watir-classic/irb-history.rb +31 -0
- data/lib/watir-classic/link.rb +46 -0
- data/lib/watir-classic/locator.rb +243 -0
- data/lib/watir-classic/logger.rb +19 -0
- data/lib/watir-classic/matches.rb +23 -0
- data/lib/watir-classic/modal_dialog.rb +72 -0
- data/lib/watir-classic/module.rb +12 -0
- data/lib/watir-classic/non_control_elements.rb +114 -0
- data/lib/watir-classic/options.rb +56 -0
- data/lib/watir-classic/page-container.rb +114 -0
- data/lib/watir-classic/process.rb +20 -0
- data/lib/watir-classic/screen_capture.rb +115 -0
- data/lib/watir-classic/supported_elements.rb +172 -0
- data/lib/watir-classic/table.rb +224 -0
- data/lib/watir-classic/testcase.rb +97 -0
- data/lib/watir-classic/util.rb +35 -0
- data/lib/watir-classic/version.rb +4 -0
- data/lib/watir-classic/wait.rb +41 -0
- data/lib/watir-classic/wait_helper.rb +12 -0
- data/lib/watir-classic/waiter.rb +98 -0
- data/lib/watir-classic/win32.rb +40 -0
- data/lib/watir-classic/win32ole.rb +16 -0
- data/lib/watir-classic/win32ole/1.8.7/win32ole.so +0 -0
- data/lib/watir-classic/win32ole/1.9.3/win32ole.so +0 -0
- data/lib/watir-classic/window.rb +68 -0
- data/lib/watir-classic/xpath_locator.rb +52 -0
- data/rakefile.rb +54 -0
- data/unittests/all_tests.rb +10 -0
- data/unittests/buttons_xpath_test.rb +68 -0
- data/unittests/checkbox_test.rb +163 -0
- data/unittests/checkbox_xpath_test.rb +106 -0
- data/unittests/click_no_wait_test.rb +23 -0
- data/unittests/close_all_test.rb +17 -0
- data/unittests/core_tests.rb +17 -0
- data/unittests/css_selector_test.rb +44 -0
- data/unittests/css_test.rb +38 -0
- data/unittests/dialog_test.rb +64 -0
- data/unittests/div2_xpath_test.rb +21 -0
- data/unittests/div_test.rb +170 -0
- data/unittests/div_xpath_test.rb +95 -0
- data/unittests/document_standards.rb +63 -0
- data/unittests/element_collection_indexes_test.rb +57 -0
- data/unittests/element_collections_test.rb +100 -0
- data/unittests/element_test.rb +47 -0
- data/unittests/errorchecker_test.rb +31 -0
- data/unittests/filefield_test.rb +43 -0
- data/unittests/filefield_xpath_test.rb +35 -0
- data/unittests/form_test.rb +282 -0
- data/unittests/form_xpath_test.rb +254 -0
- data/unittests/frame_test.rb +165 -0
- data/unittests/google_form_test.rb +15 -0
- data/unittests/html/JavascriptClick.html +39 -0
- data/unittests/html/blankpage.html +11 -0
- data/unittests/html/buttons1.html +40 -0
- data/unittests/html/checkboxes1.html +89 -0
- data/unittests/html/click_no_wait.html +14 -0
- data/unittests/html/complex_table.html +35 -0
- data/unittests/html/cssTest.html +42 -0
- data/unittests/html/depot_store.html +59 -0
- data/unittests/html/div.html +92 -0
- data/unittests/html/div_xml.html +21 -0
- data/unittests/html/fileupload.html +44 -0
- data/unittests/html/formTest1.html +38 -0
- data/unittests/html/forms2.html +44 -0
- data/unittests/html/forms3.html +131 -0
- data/unittests/html/forms4.html +26 -0
- data/unittests/html/frame_buttons.html +4 -0
- data/unittests/html/frame_links.html +4 -0
- data/unittests/html/frame_multi.html +5 -0
- data/unittests/html/google_india.html +119 -0
- data/unittests/html/ie7_document_standards.html +9 -0
- data/unittests/html/ie8_document_standards.html +9 -0
- data/unittests/html/ie9_document_standards.html +9 -0
- data/unittests/html/iframe.html +3 -0
- data/unittests/html/iframeTest.html +17 -0
- data/unittests/html/iframeTest1.html +7 -0
- data/unittests/html/iframeTest2.html +5 -0
- data/unittests/html/images/1.gif +0 -0
- data/unittests/html/images/2.GIF +0 -0
- data/unittests/html/images/3.GIF +0 -0
- data/unittests/html/images/button.jpg +0 -0
- data/unittests/html/images/circle.jpg +0 -0
- data/unittests/html/images/map.GIF +0 -0
- data/unittests/html/images/map2.gif +0 -0
- data/unittests/html/images/minus.GIF +0 -0
- data/unittests/html/images/originaltriangle.jpg +0 -0
- data/unittests/html/images/plus.gif +0 -0
- data/unittests/html/images/square.jpg +0 -0
- data/unittests/html/images/triangle.jpg +0 -0
- data/unittests/html/images1.html +65 -0
- data/unittests/html/javascriptevents.html +33 -0
- data/unittests/html/link_pass.html +11 -0
- data/unittests/html/links1.html +37 -0
- data/unittests/html/links2.html +11 -0
- data/unittests/html/links_multi.html +12 -0
- data/unittests/html/list_matters.html +720 -0
- data/unittests/html/lists.html +18 -0
- data/unittests/html/map_test.html +30 -0
- data/unittests/html/modal_dialog.html +10 -0
- data/unittests/html/modal_dialog_launcher.html +12 -0
- data/unittests/html/multiple_specifiers.html +64 -0
- data/unittests/html/nestedFrames.html +6 -0
- data/unittests/html/new_browser.html +17 -0
- data/unittests/html/pass.html +13 -0
- data/unittests/html/popups1.html +59 -0
- data/unittests/html/pre.html +29 -0
- data/unittests/html/quirks_document_standards.html +8 -0
- data/unittests/html/radioButtons1.html +71 -0
- data/unittests/html/select_tealeaf.html +54 -0
- data/unittests/html/selectboxes1.html +52 -0
- data/unittests/html/simple_table.html +25 -0
- data/unittests/html/simple_table_buttons.html +104 -0
- data/unittests/html/simple_table_columns.html +75 -0
- data/unittests/html/table1.html +179 -0
- data/unittests/html/tableCell_using_xpath.html +19 -0
- data/unittests/html/table_and_tablerow_to_a.html +174 -0
- data/unittests/html/textarea.html +30 -0
- data/unittests/html/textfields1.html +100 -0
- data/unittests/html/textsearch.html +44 -0
- data/unittests/html/wallofcheckboxes.html +1003 -0
- data/unittests/html/xpath_nbsp.html +11 -0
- data/unittests/html/zeroindex.html +11 -0
- data/unittests/ie_exists_test.rb +16 -0
- data/unittests/ie_mock.rb +94 -0
- data/unittests/ie_test.rb +54 -0
- data/unittests/images_test.rb +156 -0
- data/unittests/images_xpath_test.rb +90 -0
- data/unittests/index_specifier_test.rb +31 -0
- data/unittests/js_events_test.rb +31 -0
- data/unittests/links_multi_test.rb +34 -0
- data/unittests/links_test.rb +131 -0
- data/unittests/links_xpath_test.rb +38 -0
- data/unittests/lists_test.rb +23 -0
- data/unittests/map_test.rb +98 -0
- data/unittests/minmax_test.rb +37 -0
- data/unittests/navigate_test.rb +38 -0
- data/unittests/nbsp_xpath_test.rb +16 -0
- data/unittests/no_wait_test.rb +28 -0
- data/unittests/non_core_tests.rb +12 -0
- data/unittests/other/all_tests_concurrent.rb +57 -0
- data/unittests/other/navigate_exception_test.rb +24 -0
- data/unittests/other/rexml_unit_test.rb +27 -0
- data/unittests/other/screen_capture_test.rb +53 -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 +102 -0
- data/unittests/pagecontainstext_test.rb +69 -0
- data/unittests/parent_child_test.rb +27 -0
- data/unittests/perf_test.rb +20 -0
- data/unittests/pre_test.rb +49 -0
- data/unittests/radios_test.rb +181 -0
- data/unittests/radios_xpath_test.rb +100 -0
- data/unittests/security_setting_test.rb +24 -0
- data/unittests/selectbox_test.rb +144 -0
- data/unittests/selectbox_xpath_test.rb +102 -0
- data/unittests/setup.rb +69 -0
- data/unittests/speed_settings_test.rb +67 -0
- data/unittests/table_cell_using_xpath_test.rb +34 -0
- data/unittests/table_test.rb +296 -0
- data/unittests/table_xpath_test.rb +109 -0
- data/unittests/test_tests.rb +9 -0
- data/unittests/textarea_test.rb +92 -0
- data/unittests/textarea_xpath_test.rb +77 -0
- data/unittests/textfield_for_ch_char_test.rb +32 -0
- data/unittests/textfields_test.rb +184 -0
- data/unittests/textfields_xpath_test.rb +110 -0
- data/unittests/version_test.rb +15 -0
- data/unittests/win32ole_so_test.rb +35 -0
- data/unittests/window_tests.rb +10 -0
- data/unittests/windows/attach_to_existing_window_test.rb +52 -0
- data/unittests/windows/attach_to_new_window_test.rb +74 -0
- data/unittests/windows/close_window_test.rb +20 -0
- data/unittests/windows/frame_links_test.rb +23 -0
- data/unittests/windows/ie-each_test.rb +46 -0
- data/unittests/windows/modal_dialog_test.rb +95 -0
- data/unittests/windows/new_process_test.rb +24 -0
- data/unittests/windows/new_test.rb +58 -0
- data/unittests/windows/open_close_test.rb +19 -0
- data/unittests/windows/send_keys_test.rb +26 -0
- data/unittests/xpath_tests.rb +11 -0
- data/watir-rdoc.rb +7 -0
- metadata +370 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
|
2
|
+
require 'unittests/setup'
|
|
3
|
+
|
|
4
|
+
class TC_Performance < Test::Unit::TestCase
|
|
5
|
+
def setup
|
|
6
|
+
uses_page 'wallofcheckboxes.html'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# http://jira.openqa.org/browse/WTR-216
|
|
10
|
+
# This should take about a quarter of a second. When the bug showed up (because the
|
|
11
|
+
# fast_locate method was broken), it took nearly 10 seconds.
|
|
12
|
+
def test_access_checkbox
|
|
13
|
+
start_time = Time.now
|
|
14
|
+
browser.checkbox(:name, 'custom_monetary_value10:config.admin.required999').set
|
|
15
|
+
elapsed_time = Time.now - start_time
|
|
16
|
+
assert(elapsed_time < 1.5,
|
|
17
|
+
"Elapsed time is #{elapsed_time}, should be less than 1.5 seconds.")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# feature tests for Pre
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
|
4
|
+
require 'unittests/setup'
|
|
5
|
+
|
|
6
|
+
class TC_Pre < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
goto_page "pre.html"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_Pre_Count
|
|
13
|
+
assert( browser.pres.length == 3 )
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_Pre_Exists
|
|
17
|
+
assert_false( browser.pre( :index, 33 ).exists? )
|
|
18
|
+
assert( browser.pre( :index, 2 ).exists? )
|
|
19
|
+
|
|
20
|
+
assert( browser.pre( :id, '1' ).exists? )
|
|
21
|
+
assert( browser.pre( :id, /[3-9]/ ).exists? )
|
|
22
|
+
assert_false( browser.pre( :id, /missing_pre/ ).exists? )
|
|
23
|
+
assert_false( browser.pre( :id, 'missingPre' ).exists? )
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_simple_access
|
|
27
|
+
pre = browser.pre( :index, 0 )
|
|
28
|
+
assert( pre.text.include?( "simple pre space" ) )
|
|
29
|
+
assert_false( pre.text.include?( "A second block" ) )
|
|
30
|
+
|
|
31
|
+
pre = browser.pre( :index, 1 )
|
|
32
|
+
assert( pre.text.include?( "A second block" ) )
|
|
33
|
+
assert_false( pre.text.include?( "this is the last block" ) )
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
tag_method :test_embedded_spaces, :fails_on_firefox # http://jira.openqa.org/browse/WTR-267
|
|
37
|
+
def test_embedded_spaces
|
|
38
|
+
pre = browser.pre( :index, 2 )
|
|
39
|
+
assert( pre.text.include?( "continue to work" ) )
|
|
40
|
+
assert_false( pre.text.include?( "Pre Tag Test" ) )
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
tag_method :test_html, :fails_on_firefox # http://jira.openqa.org/browse/WTR-260
|
|
44
|
+
def test_html
|
|
45
|
+
pre = browser.pre(:index, 0)
|
|
46
|
+
assert( pre.html.gsub('"','').include?( "id=1 name=1" ) )
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# feature tests for Radio Buttons
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
|
4
|
+
require 'unittests/setup'
|
|
5
|
+
|
|
6
|
+
class TC_Radios < Test::Unit::TestCase
|
|
7
|
+
include Watir::Exception
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
goto_page "radioButtons1.html"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_Radio_Exists
|
|
14
|
+
assert(browser.radio(:name, "box1").exists?)
|
|
15
|
+
assert(browser.radio(:id, "box5").exists?)
|
|
16
|
+
|
|
17
|
+
assert_false(browser.radio(:name, "missingname").exists?)
|
|
18
|
+
assert_false(browser.radio(:id, "missingid").exists?)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_radio_class
|
|
22
|
+
assert_raises(UnknownObjectException) { browser.radio(:name, "noName").class_name }
|
|
23
|
+
assert_equal("radio_style", browser.radio(:name, "box1").class_name)
|
|
24
|
+
assert_equal("", browser.radio(:id, "box5").class_name)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_Radio_Enabled
|
|
28
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:name, "noName").enabled? }
|
|
29
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:id, "noName").enabled? }
|
|
30
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:name => "box4", :value => 6).enabled? }
|
|
31
|
+
|
|
32
|
+
assert_false(browser.radio(:name, "box2").enabled?)
|
|
33
|
+
assert(browser.radio(:id, "box5").enabled?)
|
|
34
|
+
assert(browser.radio(:name, "box1").enabled?)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_little
|
|
38
|
+
assert_false(browser.button(:value, "foo").enabled?)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_onClick
|
|
42
|
+
|
|
43
|
+
assert_false(browser.radio(:name, "box5").set?)
|
|
44
|
+
assert_false(browser.button(:value , "foo").enabled?)
|
|
45
|
+
|
|
46
|
+
# first click the button is enabled and the radio is set
|
|
47
|
+
browser.radio(:name => "box5", :value => 1).set
|
|
48
|
+
assert(browser.radio(:name => "box5", :value => 1).set?)
|
|
49
|
+
assert(browser.radio(:name => "box5", :value => 1).checked?)
|
|
50
|
+
assert(browser.button(:value, "foo").enabled?)
|
|
51
|
+
|
|
52
|
+
# second click the button is disabled and the radio is still set
|
|
53
|
+
browser.radio(:name => "box5", :value => 1).set
|
|
54
|
+
assert(browser.radio(:name => "box5", :value => 1).set?)
|
|
55
|
+
assert(browser.radio(:name => "box5", :value => 1).checked?)
|
|
56
|
+
assert_false(browser.button(:value, "foo").enabled?)
|
|
57
|
+
|
|
58
|
+
# third click the button is enabled and the radio is still set
|
|
59
|
+
browser.radio(:name => "box5", :value => 1).set
|
|
60
|
+
assert(browser.radio(:name => "box5", :value => 1).set?)
|
|
61
|
+
assert(browser.radio(:name => "box5", :value => 1).checked?)
|
|
62
|
+
assert(browser.button(:value, "foo").enabled?)
|
|
63
|
+
|
|
64
|
+
# click the radio with a value of 2 , button is disabled? and the radio is still set
|
|
65
|
+
browser.radio(:name => "box5", :value => 2).set
|
|
66
|
+
assert_false(browser.radio(:name => "box5", :value => 1).set?)
|
|
67
|
+
assert_false(browser.radio(:name => "box5", :value => 1).checked?)
|
|
68
|
+
assert(browser.radio(:name => "box5", :value => 2).set?)
|
|
69
|
+
assert(browser.radio(:name => "box5", :value => 2).checked?)
|
|
70
|
+
assert_false(browser.button(:value, "foo").enabled?)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_Radio_isSet
|
|
74
|
+
assert_raises(UnknownObjectException) { browser.radio(:name, "noName").set? }
|
|
75
|
+
|
|
76
|
+
assert_false(browser.radio(:name, "box1").set?)
|
|
77
|
+
assert( browser.radio(:name, "box3").set?)
|
|
78
|
+
assert_false(browser.radio(:name, "box2").set?)
|
|
79
|
+
assert( browser.radio(:name => "box4", :value => 1).set?)
|
|
80
|
+
assert_false(browser.radio(:name => "box4", :value => 2).set?)
|
|
81
|
+
|
|
82
|
+
assert_false(browser.radio(:name, "box1").checked?)
|
|
83
|
+
assert( browser.radio(:name, "box3").checked?)
|
|
84
|
+
assert_false(browser.radio(:name, "box2").checked?)
|
|
85
|
+
assert( browser.radio(:name => "box4", :value => 1).checked?)
|
|
86
|
+
assert_false(browser.radio(:name => "box4", :value => 2).checked?)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def test_radio_clear
|
|
90
|
+
assert_raises(UnknownObjectException) { browser.radio(:name, "noName").clear }
|
|
91
|
+
|
|
92
|
+
browser.radio(:name, "box1").clear
|
|
93
|
+
assert_false(browser.radio(:name, "box1").set?)
|
|
94
|
+
|
|
95
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:name, "box2").clear }
|
|
96
|
+
assert_false(browser.radio(:name, "box2").set?)
|
|
97
|
+
|
|
98
|
+
browser.radio(:name, "box3").clear
|
|
99
|
+
assert_false(browser.radio(:name, "box3").set?)
|
|
100
|
+
|
|
101
|
+
browser.radio(:name => "box4", :value => 1).clear
|
|
102
|
+
assert_false(browser.radio(:name => "box4", :value => 1).set?)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def test_radio_set
|
|
106
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:name, "noName").set }
|
|
107
|
+
browser.radio(:name, "box1").set
|
|
108
|
+
assert(browser.radio(:name, "box1").set?)
|
|
109
|
+
|
|
110
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:name, "box2").set }
|
|
111
|
+
|
|
112
|
+
browser.radio(:name, "box3").set
|
|
113
|
+
assert(browser.radio(:name, "box3").set?)
|
|
114
|
+
|
|
115
|
+
# radioes that have the same name but different values
|
|
116
|
+
browser.radio(:name => "box4", :value => 3).set
|
|
117
|
+
assert(browser.radio(:name => "box4", :value => 3).set?)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def test_radio_properties
|
|
121
|
+
|
|
122
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).value}
|
|
123
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).name }
|
|
124
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).id }
|
|
125
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).disabled? }
|
|
126
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).type }
|
|
127
|
+
|
|
128
|
+
assert_equal("on" , browser.radio(:index, 0).value)
|
|
129
|
+
assert_equal("box1" , browser.radio(:index, 0).name )
|
|
130
|
+
assert_equal("" , browser.radio(:index, 0).id )
|
|
131
|
+
assert_equal("radio", browser.radio(:index, 0).type )
|
|
132
|
+
|
|
133
|
+
assert_equal( false, browser.radio(:index, 0).disabled? )
|
|
134
|
+
assert_equal( true, browser.radio(:index, 2).disabled? )
|
|
135
|
+
|
|
136
|
+
assert_equal("box5" , browser.radio(:index, 1).id )
|
|
137
|
+
assert_equal("" , browser.radio(:index, 1).name )
|
|
138
|
+
|
|
139
|
+
assert_equal("box4-value5", browser.radio(:name => "box4", :value => 5).title )
|
|
140
|
+
assert_equal("", browser.radio(:name => "box4", :value => 4).title )
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def test_radio_iterators
|
|
144
|
+
assert_equal(13, browser.radios.length)
|
|
145
|
+
assert_equal("box5" , browser.radios[1].id )
|
|
146
|
+
assert_equal(true , browser.radios[2].disabled? )
|
|
147
|
+
assert_equal(false , browser.radios[0].disabled? )
|
|
148
|
+
|
|
149
|
+
index = 0
|
|
150
|
+
browser.radios.each do |r|
|
|
151
|
+
assert_equal( browser.radio(:index, index).name , r.name )
|
|
152
|
+
assert_equal( browser.radio(:index, index).id , r.id )
|
|
153
|
+
assert_equal( browser.radio(:index, index).value, r.value)
|
|
154
|
+
assert_equal( browser.radio(:index, index).disabled? , r.disabled? )
|
|
155
|
+
index+=1
|
|
156
|
+
end
|
|
157
|
+
assert_equal(index, browser.radios.length)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# test radio buttons that have a string as a value
|
|
161
|
+
def test_value_string
|
|
162
|
+
tea = browser.radio(:name => 'box6', :value => 'Tea')
|
|
163
|
+
milk = browser.radio(:name => 'box6', :value => 'Milk')
|
|
164
|
+
|
|
165
|
+
assert(tea.exists?)
|
|
166
|
+
assert(milk.exists?)
|
|
167
|
+
|
|
168
|
+
milk.set
|
|
169
|
+
assert(milk.set?)
|
|
170
|
+
assert_false(tea.set?)
|
|
171
|
+
|
|
172
|
+
tea.set
|
|
173
|
+
assert_false(milk.set?)
|
|
174
|
+
assert(tea.set?)
|
|
175
|
+
|
|
176
|
+
tea.clear
|
|
177
|
+
assert_false(tea.set?)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
end
|
|
181
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# feature tests for Radio Buttons
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
|
4
|
+
require 'unittests/setup'
|
|
5
|
+
|
|
6
|
+
class TC_Radios_XPath < Test::Unit::TestCase
|
|
7
|
+
include Watir::Exception
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
goto_page "radioButtons1.html"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_Radio_Exists
|
|
14
|
+
assert(browser.radio(:xpath, "//input[@name='box1']/").exists?)
|
|
15
|
+
assert(browser.radio(:xpath, "//input[@id='box5']/").exists?)
|
|
16
|
+
|
|
17
|
+
assert_false(browser.radio(:xpath, "//input[@name='missingname']/").exists?)
|
|
18
|
+
assert_false(browser.radio(:xpath, "//input[@id='missingid']/").exists?)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_Radio_Enabled
|
|
22
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']/").enabled? }
|
|
23
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@id='noName']/").enabled? }
|
|
24
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='box4' and @value='6']/").enabled? }
|
|
25
|
+
|
|
26
|
+
assert_false(browser.radio(:xpath, "//input[@name='box2']/").enabled?)
|
|
27
|
+
assert(browser.radio(:xpath, "//input[@id='box5']/").enabled?)
|
|
28
|
+
assert(browser.radio(:xpath, "//input[@name='box1']/").enabled?)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_little
|
|
32
|
+
assert_false(browser.button(:xpath,"//input[@name='foo']/").enabled?)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_onClick
|
|
36
|
+
assert_false(browser.button(:xpath,"//input[@name='foo']/").enabled?)
|
|
37
|
+
browser.radio(:xpath, "//input[@name='box5' and @value='1']/").set
|
|
38
|
+
assert(browser.button(:xpath,"//input[@name='foo']/").enabled?)
|
|
39
|
+
|
|
40
|
+
browser.radio(:xpath, "//input[@name='box5' and @value='2']/").set
|
|
41
|
+
assert_false(browser.button(:xpath,"//input[@name='foo']/").enabled?)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_Radio_isSet
|
|
45
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']/").isSet? }
|
|
46
|
+
|
|
47
|
+
puts "radio 1 is set : #{ browser.radio(:xpath, "//input[@name='box1']/").isSet? } "
|
|
48
|
+
assert_false(browser.radio(:xpath, "//input[@name='box1']/").isSet?)
|
|
49
|
+
|
|
50
|
+
assert(browser.radio(:xpath, "//input[@name='box3']/").isSet?)
|
|
51
|
+
assert_false(browser.radio(:xpath, "//input[@name='box2']/").isSet?)
|
|
52
|
+
|
|
53
|
+
assert( browser.radio(:xpath, "//input[@name='box4' and @value='1']/").isSet?)
|
|
54
|
+
assert_false(browser.radio(:xpath, "//input[@name='box4' and @value='2']/").isSet?)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_radio_clear
|
|
58
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']/").clear }
|
|
59
|
+
|
|
60
|
+
browser.radio(:xpath, "//input[@name='box1']/").clear
|
|
61
|
+
assert_false(browser.radio(:xpath, "//input[@name='box1']/").isSet?)
|
|
62
|
+
|
|
63
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:xpath, "//input[@name='box2']/").clear }
|
|
64
|
+
assert_false(browser.radio(:xpath, "//input[@name='box2']/").isSet?)
|
|
65
|
+
|
|
66
|
+
browser.radio(:xpath, "//input[@name='box3']/").clear
|
|
67
|
+
assert_false(browser.radio(:xpath, "//input[@name='box3']/").isSet?)
|
|
68
|
+
|
|
69
|
+
browser.radio(:xpath, "//input[@name='box4' and @value='1']/").clear
|
|
70
|
+
assert_false(browser.radio(:xpath, "//input[@name='box4' and @value='1']/").isSet?)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_radio_getState
|
|
74
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']/").getState }
|
|
75
|
+
|
|
76
|
+
assert_equal( false , browser.radio(:xpath, "//input[@name='box1']/").getState )
|
|
77
|
+
assert_equal( true , browser.radio(:xpath, "//input[@name='box3']/").getState)
|
|
78
|
+
|
|
79
|
+
# radioes that have the same name but different values
|
|
80
|
+
assert_equal( false , browser.radio(:xpath, "//input[@name='box4' and @value='2']/").getState )
|
|
81
|
+
assert_equal( true , browser.radio(:xpath, "//input[@name='box4' and @value='1']/").getState)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_radio_set
|
|
85
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']/").set }
|
|
86
|
+
browser.radio(:xpath, "//input[@name='box1']/").set
|
|
87
|
+
assert(browser.radio(:xpath, "//input[@name='box1']/").isSet?)
|
|
88
|
+
|
|
89
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:xpath, "//input[@name='box2']/").set }
|
|
90
|
+
|
|
91
|
+
browser.radio(:xpath, "//input[@name='box3']/").set
|
|
92
|
+
assert(browser.radio(:xpath, "//input[@name='box3']/").isSet?)
|
|
93
|
+
|
|
94
|
+
# radioes that have the same name but different values
|
|
95
|
+
browser.radio(:xpath, "//input[@name='box4' and @value='3']/").set
|
|
96
|
+
assert(browser.radio(:xpath, "//input[@name='box4' and @value='3']/").isSet?)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# The purpose of this test is to verify that IE has been manually
|
|
2
|
+
# configured to allow active content from local files.
|
|
3
|
+
# This setting is not really required for normal use of Watir, but
|
|
4
|
+
# it is essential for many of our unit tests.
|
|
5
|
+
|
|
6
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
|
7
|
+
require 'unittests/setup'
|
|
8
|
+
|
|
9
|
+
class TC_AAA_Security_Settings < Test::Unit::TestCase
|
|
10
|
+
def setup
|
|
11
|
+
uses_page "div.html"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
@@security_instructions = "\
|
|
15
|
+
You must change your IE security settings to run these tests.
|
|
16
|
+
Tools -> Internet Options -> Advanced -> Security ->
|
|
17
|
+
'Allow active content to run in files on My Computer'"
|
|
18
|
+
|
|
19
|
+
def test_active_content
|
|
20
|
+
browser.span(:id, "span3").click
|
|
21
|
+
value = browser.text_field(:name, "text2").value
|
|
22
|
+
fail(@@security_instructions) if value == '0'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# feature tests for Select Boxes
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
|
4
|
+
require 'unittests/setup'
|
|
5
|
+
|
|
6
|
+
class TC_SelectList < Test::Unit::TestCase
|
|
7
|
+
include Watir::Exception
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
goto_page "selectboxes1.html"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_exists
|
|
14
|
+
assert(browser.select_list(:name, "sel1").exists?)
|
|
15
|
+
assert_false(browser.select_list(:name, "missing").exists?)
|
|
16
|
+
assert_false(browser.select_list(:id, "missing").exists?)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_enabled
|
|
20
|
+
assert(browser.select_list(:name, "sel1").enabled?)
|
|
21
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").enabled? }
|
|
22
|
+
assert_false(browser.select_list(:id, 'selectbox_4').enabled?)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_class_name
|
|
26
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "missing").class_name }
|
|
27
|
+
assert_equal("list_style", browser.select_list(:name, "sel1").class_name)
|
|
28
|
+
assert_equal("", browser.select_list(:name, "sel2").class_name)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_select_by_text
|
|
32
|
+
assert_equal('Option 3', browser.select_list(:name, "sel1").selected_options.first.text)
|
|
33
|
+
browser.select_list(:name, "sel1").select('Option 2')
|
|
34
|
+
assert_equal('Option 2', browser.select_list(:name, "sel1").selected_options.first.text)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_select_by_value
|
|
38
|
+
browser.select_list(:name, "sel3").select_value(/2/)
|
|
39
|
+
assert(browser.text.include?("PASS"))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Option
|
|
43
|
+
|
|
44
|
+
def test_Option_text_select
|
|
45
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").select }
|
|
46
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, /missing/).select }
|
|
47
|
+
assert_raises(MissingWayOfFindingObjectException) { browser.select_list(:name, "sel1").option(:missing, "Option 1").select }
|
|
48
|
+
|
|
49
|
+
browser.select_list(:name, "sel1").option(:text, "Option 1").select
|
|
50
|
+
assert_equal("Option 1", browser.select_list(:name, "sel1").selected_options.first.text)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_clear_selection
|
|
54
|
+
assert_raises(TypeError) { browser.select_list(:name, "sel1").clear }
|
|
55
|
+
assert_nothing_thrown { browser.select_list(:name, "sel2").clear }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def xtest_option_class_name
|
|
59
|
+
# the option object doesnt inherit from element, so this doesnt work
|
|
60
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").class_name }
|
|
61
|
+
assert_equal("list_style", browser.select_list(:name, "sel2").option(:value, 'o2').class_name)
|
|
62
|
+
assert_equal("", browser.select_list(:name, "sel2").option(:value, 'o1').class_name)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# SelectList#includes?
|
|
66
|
+
|
|
67
|
+
tag_method :test_includes, :fails_on_firefox
|
|
68
|
+
def test_includes
|
|
69
|
+
assert browser.select_list(:name, 'sel1').include?('Option 1')
|
|
70
|
+
assert browser.select_list(:name, 'sel1').include?(/option/i)
|
|
71
|
+
assert ! browser.select_list(:name, 'sel1').include?('Option 6')
|
|
72
|
+
assert ! browser.select_list(:name, 'sel1').include?(/foobar/)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# SelectList#selected?
|
|
76
|
+
|
|
77
|
+
tag_method :test_selected, :fails_on_firefox
|
|
78
|
+
def test_selected
|
|
79
|
+
assert browser.select_list(:name, 'sel1').selected?('Option 3')
|
|
80
|
+
assert browser.select_list(:name, 'sel1').selected?(/option/i)
|
|
81
|
+
assert ! browser.select_list(:name, 'sel1').selected?('Option 1')
|
|
82
|
+
assert ! browser.select_list(:name, 'sel1').selected?(/option 1/i)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
tag_method :test_selected_not_found, :fails_on_firefox
|
|
86
|
+
def test_selected_not_found
|
|
87
|
+
selectbox = browser.select_list(:name, 'sel1')
|
|
88
|
+
assert_raises(UnknownObjectException) {selectbox.selected?("option doesn't exist")}
|
|
89
|
+
assert_raises(UnknownObjectException) {selectbox.selected?(/option doesn't exist/)}
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_properties
|
|
94
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).value }
|
|
95
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).name }
|
|
96
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).id }
|
|
97
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).disabled? }
|
|
98
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).type }
|
|
99
|
+
|
|
100
|
+
assert_equal("o3" , browser.select_list(:index, 0).value)
|
|
101
|
+
assert_equal("sel1" , browser.select_list(:index, 0).name)
|
|
102
|
+
assert_equal("" , browser.select_list(:index, 0).id)
|
|
103
|
+
assert_equal("select-one", browser.select_list(:index, 0).type)
|
|
104
|
+
assert_equal("select-multiple", browser.select_list(:index, 1).type)
|
|
105
|
+
|
|
106
|
+
browser.select_list(:index,0).select(/1/)
|
|
107
|
+
assert_equal("o1", browser.select_list(:index, 0).value)
|
|
108
|
+
|
|
109
|
+
assert_false( browser.select_list(:index, 0).disabled?)
|
|
110
|
+
assert(browser.select_list(:index, 3).disabled?)
|
|
111
|
+
assert(browser.select_list(:id, 'selectbox_4').disabled?)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def test_iterator
|
|
115
|
+
assert_equal(4, browser.select_lists.length)
|
|
116
|
+
assert_equal("o3" , browser.select_lists[0].value)
|
|
117
|
+
assert_equal("sel1" , browser.select_lists[0].name )
|
|
118
|
+
assert_equal("select-one", browser.select_lists[0].type )
|
|
119
|
+
assert_equal("select-multiple" , browser.select_lists[1].type )
|
|
120
|
+
|
|
121
|
+
index = 0
|
|
122
|
+
browser.select_lists.each do |l|
|
|
123
|
+
assert_equal( browser.select_list(:index, index).name, l.name)
|
|
124
|
+
assert_equal( browser.select_list(:index, index).id, l.id)
|
|
125
|
+
assert_equal( browser.select_list(:index, index).type, l.type)
|
|
126
|
+
assert_equal( browser.select_list(:index, index).value, l.value)
|
|
127
|
+
index += 1
|
|
128
|
+
end
|
|
129
|
+
assert_equal(index, browser.select_lists.length)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
class TC_Select_Options < Test::Unit::TestCase
|
|
134
|
+
|
|
135
|
+
def setup
|
|
136
|
+
goto_page "select_tealeaf.html"
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def test_options_text
|
|
140
|
+
browser.select_list(:name, 'op_numhits').option(:text, '>=').select
|
|
141
|
+
assert(browser.select_list(:name, 'op_numhits').option(:text, '>=').selected?)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|