watir-classic 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,106 @@
|
|
1
|
+
# feature tests for Check Boxes
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
|
6
|
+
class TC_CheckBox_XPath < Test::Unit::TestCase
|
7
|
+
include Watir::Exception
|
8
|
+
|
9
|
+
def setup
|
10
|
+
goto_page "checkboxes1.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_checkbox_properties
|
14
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").id }
|
15
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").name }
|
16
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").disabled }
|
17
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").type }
|
18
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").value }
|
19
|
+
|
20
|
+
assert_equal("1" , browser.checkbox(:xpath , "//input[@name='box4']/").value )
|
21
|
+
assert_equal("3" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").value )
|
22
|
+
assert_equal("checkbox" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").type )
|
23
|
+
assert_equal(false , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").disabled )
|
24
|
+
assert_equal("" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").id )
|
25
|
+
|
26
|
+
assert_equal("box4-value5" , browser.checkbox(:xpath , "//input[@name='box4' and @value='5']/").title)
|
27
|
+
assert_equal("" , browser.checkbox(:xpath , "//input[@name='box4' and @value='4']/").title)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_CheckBox_Exists
|
31
|
+
assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']/").exists?)
|
32
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='22']/").exists?)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_checkbox_Enabled
|
36
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").enabled? }
|
37
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@id='noName']/").enabled? }
|
38
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='box4' and @value='6']/").enabled? }
|
39
|
+
|
40
|
+
assert(browser.checkbox(:xpath , "//input[@name='box1']/").enabled?)
|
41
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box2']/").enabled?)
|
42
|
+
|
43
|
+
assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='4']/").enabled?)
|
44
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='5']/").enabled?)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_checkbox_isSet
|
48
|
+
assert_raises(UnknownObjectException ) { browser.checkbox(:xpath , "//input[@name='noName']/").isSet? }
|
49
|
+
|
50
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box1']/").isSet?)
|
51
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box2']/").isSet?)
|
52
|
+
assert(browser.checkbox(:xpath , "//input[@name='box3']/").isSet?)
|
53
|
+
|
54
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='2']/").isSet?)
|
55
|
+
assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']/").isSet?)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_checkbox_clear
|
59
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").clear }
|
60
|
+
browser.checkbox(:xpath , "//input[@name='box1']/").clear
|
61
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box1']/").isSet?)
|
62
|
+
|
63
|
+
assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']/").clear }
|
64
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box2']/").isSet?)
|
65
|
+
|
66
|
+
browser.checkbox(:xpath , "//input[@name='box3']/").clear
|
67
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box3']/").isSet?)
|
68
|
+
|
69
|
+
browser.checkbox(:xpath , "//input[@name='box4' and @value='1']/").clear
|
70
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']/").isSet?)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_checkbox_getState
|
74
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").getState }
|
75
|
+
assert_equal( false , browser.checkbox(:xpath , "//input[@name='box1']/").getState )
|
76
|
+
assert_equal( true , browser.checkbox(:xpath , "//input[@name='box3']/").getState)
|
77
|
+
|
78
|
+
# checkboxes that have the same name but different values
|
79
|
+
assert_equal( false , browser.checkbox(:xpath , "//input[@name='box4' and @value='2']/").getState )
|
80
|
+
assert_equal( true , browser.checkbox(:xpath , "//input[@name='box4' and @value='1']/").getState)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_checkbox_set
|
84
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").set }
|
85
|
+
browser.checkbox(:xpath , "//input[@name='box1']/").set
|
86
|
+
assert(browser.checkbox(:xpath , "//input[@name='box1']/").isSet?)
|
87
|
+
|
88
|
+
assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']/").set }
|
89
|
+
|
90
|
+
browser.checkbox(:xpath , "//input[@name='box3']/").set
|
91
|
+
assert(browser.checkbox(:xpath , "//input[@name='box3']/").isSet?)
|
92
|
+
|
93
|
+
# checkboxes that have the same name but different values
|
94
|
+
browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").set
|
95
|
+
assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").isSet?)
|
96
|
+
|
97
|
+
# test set using the optinal true/false
|
98
|
+
# assumes the checkbox is already checked
|
99
|
+
browser.checkbox(:xpath , "//input[@name='box1']/").set( false )
|
100
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box1']/").isSet?)
|
101
|
+
|
102
|
+
browser.checkbox(:xpath , "//input[@name='box1']/").set( true )
|
103
|
+
assert(browser.checkbox(:xpath , "//input[@name='box1']/").isSet?)
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
2
|
+
require 'unittests/setup'
|
3
|
+
|
4
|
+
class ClickNoWait_Tests < Watir::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
goto_page 'click_no_wait.html'
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_click_no_wait
|
11
|
+
message_div = browser.div(:id => 'div1')
|
12
|
+
assert_equal("nothing", message_div.text)
|
13
|
+
browser.link(:id => 'link1').click_no_wait
|
14
|
+
assert_nothing_raised {
|
15
|
+
Watir::Wait.until {message_div.text == "message!"}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_spawned_click_no_wait_command
|
20
|
+
assert_equal("start rubyw -e \"some command\"", browser.link(:id => 'link1').send(:spawned_no_wait_command, "some command"))
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
2
|
+
require 'unittests/setup'
|
3
|
+
|
4
|
+
class TC_CloseAllWindows < Watir::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@browsers = []
|
8
|
+
5.times {@browsers << Watir::Browser.new}
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_close_all_windows
|
12
|
+
assert @browsers.all? {|browser| browser.exists?}
|
13
|
+
Watir::IE.close_all
|
14
|
+
assert @browsers.all? {|browser| not browser.exists?}
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# these are the non-xpath tests that do not need to be visible
|
2
|
+
|
3
|
+
$HIDE_IE = true
|
4
|
+
|
5
|
+
TOPDIR = File.join(File.dirname(__FILE__), '..')
|
6
|
+
|
7
|
+
$LOAD_PATH.unshift TOPDIR
|
8
|
+
require 'unittests/setup'
|
9
|
+
|
10
|
+
Dir.chdir TOPDIR do
|
11
|
+
$all_tests.each {|x| require x}
|
12
|
+
end
|
13
|
+
|
14
|
+
Watir::UnitTest.filter_out do |test|
|
15
|
+
test.class.to_s =~ /xpath/i
|
16
|
+
end
|
17
|
+
Watir::UnitTest.filter_out_tests_tagged :must_be_visible
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Feature tests for CSS selectors.
|
2
|
+
#
|
3
|
+
# Only shallow testing is needed since the selectors are immediately
|
4
|
+
# converted to xpath and the other xpath tests will provide coverage
|
5
|
+
# for the returned objects. This test more or less only verifies that the
|
6
|
+
# respective classes have implemented the css selector as a query option.
|
7
|
+
#
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
10
|
+
require 'unittests/setup'
|
11
|
+
|
12
|
+
class TC_CSS_Selector < Test::Unit::TestCase
|
13
|
+
include Watir::Exception
|
14
|
+
|
15
|
+
# Same test as TC_Divs_XPath::test_divs but using css selectors instead
|
16
|
+
def test_matching_queries
|
17
|
+
goto_page "div.html"
|
18
|
+
|
19
|
+
assert_raises(UnknownObjectException) {browser.div(:css , "div[id='div77']").click }
|
20
|
+
assert_raises(UnknownObjectException) {browser.div(:css , "div[title='div77']").click }
|
21
|
+
|
22
|
+
assert(browser.text_field(:css, "input[name='text1']").verify_contains("0") )
|
23
|
+
browser.div(:css , "div[id='div3']").click
|
24
|
+
assert(browser.text_field(:css, "input[ name = 'text1' ]").verify_contains("1") )
|
25
|
+
browser.div(:css , "div[id = div4]").click
|
26
|
+
assert(browser.text_field(:css, "input[name=text1]").verify_contains("0") )
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_form
|
30
|
+
goto_page "forms2.html"
|
31
|
+
assert(browser.form(:css, "#f2").action =~ /pass2.html$/)
|
32
|
+
assert_equal(browser.button(:css, "form #b2").value, "Click Me")
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_image
|
36
|
+
goto_page "div.html"
|
37
|
+
assert_equal( "circle", browser.image(:css, "*[id ^= 'circ']").id )
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_table
|
41
|
+
goto_page "table1.html"
|
42
|
+
assert_equal( "Header", browser.th(:css , ".sample th").text )
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# feature tests for css
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
|
6
|
+
class TC_CSS < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def isMessageDisplayed(message)
|
9
|
+
divs = browser.divs
|
10
|
+
divs.each do |d|
|
11
|
+
if d.text.downcase.match( /#{message}/i )
|
12
|
+
if d.class_name.downcase.match(/show/i)
|
13
|
+
return true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup
|
22
|
+
goto_page "cssTest.html"
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_SuccessMessage
|
26
|
+
browser.button( :caption , "Success").click
|
27
|
+
assert( isMessageDisplayed("Success") )
|
28
|
+
|
29
|
+
browser.button(:caption, "Failure").click
|
30
|
+
assert_false(isMessageDisplayed("Success") )
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_inline_style
|
34
|
+
assert_match(/300px/, browser.form(:index, 0).style)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Feature tests for Dialog class
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
|
6
|
+
class TC_Dialog_Test < Test::Unit::TestCase
|
7
|
+
tags :must_be_visible
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
goto_page 'JavascriptClick.html'
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_alert_without_bonus_script
|
15
|
+
browser.button(:id, 'btnAlert').click_no_wait
|
16
|
+
browser.javascript_dialog.button("OK").click
|
17
|
+
assert_match(/Alert button!/, browser.text_field(:id, "testResult").value)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_button_name_not_found
|
21
|
+
browser.button(:id, 'btnAlert').click_no_wait
|
22
|
+
original_timeout = RAutomation::Window.wait_timeout
|
23
|
+
RAutomation::Window.wait_timeout = 5
|
24
|
+
assert_raises(::RAutomation::UnknownButtonException) {browser.javascript_dialog.button("Yes").click}
|
25
|
+
RAutomation::Window.wait_timeout = original_timeout
|
26
|
+
browser.javascript_dialog.button("OK").click
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_exists
|
30
|
+
assert_false(browser.javascript_dialog.exists?)
|
31
|
+
browser.button(:id, 'btnAlert').click_no_wait
|
32
|
+
Watir::Wait.until(5) {browser.javascript_dialog.exists?}
|
33
|
+
browser.javascript_dialog.button("OK").click
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_copy_array_elements
|
37
|
+
a = ['a', 'b', 'c']
|
38
|
+
copy = Array.new(a)
|
39
|
+
c = []
|
40
|
+
code = _code_that_copies_readonly_array(a, "c")
|
41
|
+
eval code
|
42
|
+
assert_equal copy, c
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_confirm_ok
|
46
|
+
browser.button(:value, 'confirm').click_no_wait
|
47
|
+
Watir::Wait.until(5) {browser.javascript_dialog.exists?}
|
48
|
+
browser.javascript_dialog.button("OK").click
|
49
|
+
assert_equal "You pressed the Confirm and OK button!", browser.text_field(:id, 'testResult').value
|
50
|
+
end
|
51
|
+
|
52
|
+
def xtest_confirm_cancel
|
53
|
+
browser.button(:value, 'confirm').click_no_wait
|
54
|
+
assert browser.javascript_dialog.exists?
|
55
|
+
browser.javascript_dialog.button("Cancel").click
|
56
|
+
assert_equal "You pressed the Confirm and Cancel button!", browser.text_field(:id, 'testResult').value
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_dialog_close
|
60
|
+
browser.javascript_dialog.close
|
61
|
+
assert !browser.javascript_dialog.exists?
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# defect reproduction
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
|
6
|
+
class TC_Divs_XPath2 < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
goto_page "list_matters.html"
|
9
|
+
end
|
10
|
+
def test_div_with_text
|
11
|
+
# Note: this test fails, probably because of bad html to xml translation.
|
12
|
+
# However... the same xpath expression finds the right object in Selenium!
|
13
|
+
assert_equal('Add', browser.div(:xpath, "//div[text()='Add' and @class='ButtonText']").text)
|
14
|
+
end
|
15
|
+
def test_div_with_contains
|
16
|
+
# Note: this test fails, probably because of bad html to xml translation.
|
17
|
+
# However... the same xpath expression finds the right object in Selenium!
|
18
|
+
assert_equal('Add', browser.div(:xpath, "//div[contains(.,'Add') and @class='ButtonText']").text)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
# feature tests for Divs, Spans and P's
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
|
6
|
+
class TC_Divs < Test::Unit::TestCase
|
7
|
+
include Watir::Exception
|
8
|
+
|
9
|
+
def setup
|
10
|
+
uses_page "div.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
tag_method :test_div_properties, :fails_on_firefox
|
14
|
+
def test_div_properties
|
15
|
+
assert_raises(UnknownObjectException) { browser.div(:id, "div77").text }
|
16
|
+
assert_raises(UnknownObjectException) { browser.div(:title, "div77").text }
|
17
|
+
|
18
|
+
assert_equal("This div has an onClick that increments text1",
|
19
|
+
browser.div(:id , "div3").text.strip )
|
20
|
+
assert_equal("This text is in a div with an id of div1 and title of test1",
|
21
|
+
browser.div(:title , "Test1").text.strip )
|
22
|
+
|
23
|
+
assert_raises(UnknownObjectException) { browser.div(:id , "div77").class_name }
|
24
|
+
assert_equal("blueText", browser.div(:id, "div2").class_name)
|
25
|
+
assert_equal("", browser.div(:id, "div1").class_name)
|
26
|
+
|
27
|
+
assert_raises(UnknownObjectException) { browser.div(:index, 43).class_name }
|
28
|
+
assert_equal("div1" , browser.div(:index, 0).id)
|
29
|
+
assert_equal("" , browser.div(:index, 0).class_name)
|
30
|
+
assert_equal("blueText" , browser.div(:index, 1).class_name)
|
31
|
+
assert_equal(false , browser.div(:index, 1).disabled?)
|
32
|
+
assert_equal("div2", browser.div(:index, 1).id)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_div_iterator
|
36
|
+
assert_equal(8, browser.divs.length)
|
37
|
+
assert_equal("div1", browser.divs[0].id)
|
38
|
+
|
39
|
+
index = 0
|
40
|
+
browser.divs.each do |s|
|
41
|
+
assert_equal(browser.div(:index,index).id, s.id)
|
42
|
+
assert_equal(browser.div(:index,index).class_name , s.class_name)
|
43
|
+
index += 1
|
44
|
+
end
|
45
|
+
assert_equal(index, browser.divs.length)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_enumerable
|
49
|
+
match = browser.divs.detect{|d| d.class_name == 'blueText'}
|
50
|
+
assert_equal('div2', match.id)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_objects_in_div
|
54
|
+
assert browser.div(:id, 'buttons1').button(:index,0).exists?
|
55
|
+
assert !browser.div(:id, 'buttons1').button(:index,2).exists?
|
56
|
+
assert browser.div(:id, 'buttons1').button(:name,'b1').exists?
|
57
|
+
|
58
|
+
assert browser.div(:id, 'buttons2').button(:index,0).exists?
|
59
|
+
assert browser.div(:id, 'buttons2').button(:index,1).exists?
|
60
|
+
assert !browser.div(:id, 'buttons1').button(:index,2).exists?
|
61
|
+
|
62
|
+
browser.div(:id, 'buttons1').button(:index, 0).click
|
63
|
+
assert_equal('button1', browser.div(:id, 'text_fields1').text_field(:index,0).value)
|
64
|
+
|
65
|
+
assert_equal(3, browser.div(:id, 'text_fields1').text_fields.length )
|
66
|
+
browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').set("drink me")
|
67
|
+
assert_equal("drink me", browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').value)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_images_inside_a_div
|
71
|
+
assert_equal(3, browser.div(:id, 'hasImages').images.length)
|
72
|
+
assert_match(/triangle/, browser.div(:id, 'hasImages').images[0].src)
|
73
|
+
assert_match(/circle/, browser.div(:id, 'hasImages').image(:id , 'circle').src)
|
74
|
+
end
|
75
|
+
|
76
|
+
#---- Span Tests ---
|
77
|
+
def test_spans
|
78
|
+
assert_raises(UnknownObjectException) {browser.span(:id, "span77").click }
|
79
|
+
assert_raises(UnknownObjectException) {browser.span(:title, "span77").click }
|
80
|
+
|
81
|
+
assert(browser.text_field(:name, "text2").verify_contains("0") )
|
82
|
+
browser.span(:id, "span3").click
|
83
|
+
assert(browser.text_field(:name, "text2").verify_contains("1") )
|
84
|
+
|
85
|
+
browser.span(:id, "span4").click
|
86
|
+
assert(browser.text_field(:name, "text2").verify_contains("0") )
|
87
|
+
end
|
88
|
+
|
89
|
+
tag_method :test_span_properties, :fails_on_firefox
|
90
|
+
def test_span_properties
|
91
|
+
assert_raises(UnknownObjectException) {browser.span(:id, "span77").text }
|
92
|
+
assert_raises(UnknownObjectException) {browser.span(:title, "span77").text }
|
93
|
+
|
94
|
+
assert_equal("This span has an onClick that increments text2",
|
95
|
+
browser.span(:id , "span3").text.strip )
|
96
|
+
assert_equal("This text is in a span with an id of span1 and title of test2",
|
97
|
+
browser.span(:title , "Test2").text.strip)
|
98
|
+
|
99
|
+
assert_raises(UnknownObjectException) {browser.span(:id, "span77").class_name}
|
100
|
+
assert_equal("blueText", browser.span(:id, "span2").class_name)
|
101
|
+
assert_equal("", browser.span(:id, "span1").class_name)
|
102
|
+
|
103
|
+
assert_raises(UnknownObjectException) {browser.span(:index , 43).class_name }
|
104
|
+
assert_equal("span1" , browser.span(:index , 0).id )
|
105
|
+
assert_equal("" , browser.span(:index , 0).class_name )
|
106
|
+
assert_equal("blueText" , browser.span(:index , 1).class_name )
|
107
|
+
assert_equal(false , browser.span(:index , 1).disabled?)
|
108
|
+
assert_equal("span2", browser.span(:index , 1).id)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_span_iterator
|
112
|
+
assert_equal(7, browser.spans.length)
|
113
|
+
assert_equal("span1", browser.spans[0].id)
|
114
|
+
|
115
|
+
index = 0
|
116
|
+
browser.spans.each do |s|
|
117
|
+
assert_equal(browser.span(:index, index ).id , s.id )
|
118
|
+
assert_equal(browser.span(:index, index ).class_name , s.class_name )
|
119
|
+
index += 1
|
120
|
+
end
|
121
|
+
assert_equal(index, browser.spans.length)
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_objects_in_span
|
125
|
+
assert(browser.span(:id, 'buttons1').button(:index,0).exists? )
|
126
|
+
assert_false(browser.span(:id, 'buttons1').button(:index,2).exists? )
|
127
|
+
assert(browser.span(:id, 'buttons1').button(:name,'b1').exists? )
|
128
|
+
|
129
|
+
assert(browser.span(:id, 'buttons2').button(:index,0).exists? )
|
130
|
+
assert(browser.span(:id, 'buttons2').button(:index,1).exists? )
|
131
|
+
assert_false(browser.span(:id, 'buttons1').button(:index,2).exists? )
|
132
|
+
|
133
|
+
browser.span(:id, 'buttons1').button(:index,0).click
|
134
|
+
assert_equal( 'button1' , browser.span(:id , 'text_fields1').text_field(:index,0).value)
|
135
|
+
assert_equal( 3 , browser.span(:id , 'text_fields1').text_fields.length )
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_p
|
139
|
+
assert(browser.p(:id, 'number1').exists?)
|
140
|
+
assert(browser.p(:index, 2).exists?)
|
141
|
+
assert(browser.p(:title, 'test_3').exists?)
|
142
|
+
|
143
|
+
assert_false(browser.p(:id, 'missing').exists?)
|
144
|
+
assert_false(browser.p(:index, 7).exists?)
|
145
|
+
assert_false(browser.p(:title, 'test_55').exists?)
|
146
|
+
|
147
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').class_name }
|
148
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').text }
|
149
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').title }
|
150
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').to_s }
|
151
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').disabled? }
|
152
|
+
|
153
|
+
assert_equal('redText' , browser.p(:index,0).class_name)
|
154
|
+
assert_equal('P_tag_1' , browser.p(:index,0).title)
|
155
|
+
assert_equal('This text is in a p with an id of number2' , browser.p(:index,1).text)
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_p_iterator
|
159
|
+
assert_equal(3, browser.ps.length)
|
160
|
+
assert_equal('italicText', browser.ps[1].class_name)
|
161
|
+
assert_equal('number3', browser.ps[2].id)
|
162
|
+
|
163
|
+
count = 1
|
164
|
+
browser.ps.each do |p|
|
165
|
+
assert_equal('number'+count.to_s, p.id)
|
166
|
+
count += 1
|
167
|
+
end
|
168
|
+
assert_equal(count - 1, browser.ps.length)
|
169
|
+
end
|
170
|
+
end
|