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,102 @@
|
|
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_Selectbox_XPath < Test::Unit::TestCase
|
7
|
+
include Watir::Exception
|
8
|
+
|
9
|
+
def setup
|
10
|
+
goto_page "selectboxes1.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_textBox_Exists
|
14
|
+
assert(browser.select_list(:xpath, "//select[@name='sel1']/").exists?)
|
15
|
+
assert_false(browser.select_list(:xpath, "//select[@name='missing']/").exists?)
|
16
|
+
assert_false(browser.select_list(:xpath, "//select[@id='missing']/").exists?)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_select_list_enabled
|
20
|
+
assert(browser.select_list(:xpath, "//select[@name='sel1']/").enabled?)
|
21
|
+
assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").enabled? }
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_select_list_getAllContents
|
25
|
+
assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getAllContents }
|
26
|
+
assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
|
27
|
+
browser.select_list(:xpath, "//select[@name='sel1']/").options.map(&:text))
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_select_list_getSelectedItems
|
31
|
+
assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
|
32
|
+
assert_equal( ["Option 3" ] ,
|
33
|
+
browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text))
|
34
|
+
assert_equal( ["Option 3" , "Option 6" ] ,
|
35
|
+
browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text))
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_clearSelection
|
39
|
+
browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection
|
40
|
+
assert_equal( [ ] , browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text))
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_select_list_select
|
44
|
+
assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").selected_options.map(&:text) }
|
45
|
+
assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select("missing item") }
|
46
|
+
assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select(/missing/) }
|
47
|
+
|
48
|
+
# the select method keeps any currently selected items - use the clear selectcion method first
|
49
|
+
browser.select_list(:xpath, "//select[@name='sel1']/").select("Option 1")
|
50
|
+
assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text))
|
51
|
+
|
52
|
+
browser.select_list(:xpath, "//select[@name='sel1']/").select(/2/)
|
53
|
+
assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text))
|
54
|
+
|
55
|
+
browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection
|
56
|
+
browser.select_list(:xpath, "//select[@name='sel2']/").select( /2/ )
|
57
|
+
browser.select_list(:xpath, "//select[@name='sel2']/").select( /4/ )
|
58
|
+
assert_equal( ["Option 2" , "Option 4" ] ,
|
59
|
+
browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text))
|
60
|
+
|
61
|
+
# these are to test the onchange event
|
62
|
+
# the event shouldnt get fired, as this is the selected item
|
63
|
+
browser.select_list(:xpath, "//select[@name='sel3']/").select( /3/ )
|
64
|
+
assert_false(browser.text.include?("Pass") )
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_select_list_select2
|
68
|
+
# the event should get fired
|
69
|
+
browser.select_list(:xpath, "//select[@name='sel3']/").select( /2/ )
|
70
|
+
assert(browser.text.include?("PASS") )
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_select_list_select_using_value
|
74
|
+
assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
|
75
|
+
assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select_value("missing item") }
|
76
|
+
assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select_value(/missing/) }
|
77
|
+
|
78
|
+
# the select method keeps any currently selected items - use the clear selectcion method first
|
79
|
+
browser.select_list(:xpath, "//select[@name='sel1']/").select_value("o1")
|
80
|
+
assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text))
|
81
|
+
|
82
|
+
browser.select_list(:xpath, "//select[@name='sel1']/").select_value(/2/)
|
83
|
+
assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text))
|
84
|
+
|
85
|
+
browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection
|
86
|
+
browser.select_list(:xpath, "//select[@name='sel2']/").select( /2/ )
|
87
|
+
browser.select_list(:xpath, "//select[@name='sel2']/").select( /4/ )
|
88
|
+
assert_equal( ["Option 2" , "Option 4" ] , browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text))
|
89
|
+
|
90
|
+
# these are to test the onchange event
|
91
|
+
# the event shouldnt get fired, as this is the selected item
|
92
|
+
browser.select_list(:xpath, "//select[@name='sel3']/").select_value( /3/ )
|
93
|
+
assert_false(browser.text.include?("Pass") )
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_select_list_select_using_value2
|
97
|
+
# the event should get fired
|
98
|
+
browser.select_list(:xpath, "//select[@name='sel3']/").select_value( /2/ )
|
99
|
+
assert(browser.text.include?("PASS") )
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
data/unittests/setup.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# watir/unittests/setup.rb
|
2
|
+
$SETUP_LOADED = true
|
3
|
+
$myDir = File.expand_path(File.dirname(__FILE__))
|
4
|
+
|
5
|
+
def append_to_load_path path
|
6
|
+
$LOAD_PATH.unshift File.expand_path(path)
|
7
|
+
end
|
8
|
+
|
9
|
+
# use local development versions of watir
|
10
|
+
topdir = File.join(File.dirname(__FILE__), '..')
|
11
|
+
$watir_dev_lib = File.join(topdir, 'lib')
|
12
|
+
commonwatir_dir = "commonwatir#{File.exist?('VERSION') ? "-#{File.read('VERSION').strip}" : ""}"
|
13
|
+
commonwatir_absolute_dir = File.join(topdir, '..', commonwatir_dir)
|
14
|
+
libs = []
|
15
|
+
libs << File.join(commonwatir_absolute_dir, 'lib')
|
16
|
+
libs << commonwatir_absolute_dir # for the unit tests
|
17
|
+
libs.each { |lib| append_to_load_path(lib) }
|
18
|
+
|
19
|
+
require 'watir-classic/browser'
|
20
|
+
Watir::Browser.default = 'ie'
|
21
|
+
require 'unittests/setup/lib'
|
22
|
+
require 'watir-classic/testcase'
|
23
|
+
|
24
|
+
# Standard Tags
|
25
|
+
# :must_be_visible
|
26
|
+
# :creates_windows
|
27
|
+
# :unreliable (test fails intermittently)
|
28
|
+
|
29
|
+
=begin
|
30
|
+
Test Suites
|
31
|
+
* all_tests -- all the tests in the unittests directory (omits "other")
|
32
|
+
* window_tests -- window intensive tests
|
33
|
+
=end
|
34
|
+
|
35
|
+
$all_tests = []
|
36
|
+
$all_tests += Dir["unittests/*_test.rb"]
|
37
|
+
Dir.chdir commonwatir_absolute_dir do
|
38
|
+
$all_tests += Dir["unittests/*_test.rb"]
|
39
|
+
end
|
40
|
+
|
41
|
+
# These tests won't load unless Watir is in the path
|
42
|
+
$watir_only_tests = [
|
43
|
+
"images_xpath_test.rb",
|
44
|
+
"images_test.rb",
|
45
|
+
"dialog_test.rb",
|
46
|
+
"ie_test.rb"
|
47
|
+
].map {|file| "unittests/#{file}"}
|
48
|
+
|
49
|
+
if Watir::UnitTest.options[:browser] != 'ie'
|
50
|
+
$all_tests -= $watir_only_tests
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
=begin
|
55
|
+
'attach_to_existing_window', # could actually run robustly as part of the core suite!
|
56
|
+
'attach_to_new_window', # creates new window
|
57
|
+
'close_window', # creates new window
|
58
|
+
'frame_links', # visible
|
59
|
+
'iedialog', # visible
|
60
|
+
#ie-each
|
61
|
+
'js_events', # is always visible
|
62
|
+
'jscript',
|
63
|
+
'modal_dialog', # modal is visible
|
64
|
+
#new
|
65
|
+
'open_close',
|
66
|
+
'send_keys', # visible
|
67
|
+
=end
|
68
|
+
|
69
|
+
$window_tests = Dir["unittests/windows/*_test.rb"] - ["unittests/windows/ie-each_test.rb"]
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# tests for ability to set defaults for Watir
|
2
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
3
|
+
require 'unittests/setup'
|
4
|
+
|
5
|
+
class TC_instance_options < Test::Unit::TestCase
|
6
|
+
tags :fails_on_firefox
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@ie4 = Watir::IE.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_using_default
|
13
|
+
@ie4.speed = :fast
|
14
|
+
assert_equal(:fast, @ie4.speed)
|
15
|
+
@ie4.speed = :slow
|
16
|
+
assert_equal(:slow, @ie4.speed)
|
17
|
+
@ie4.speed = :zippy
|
18
|
+
assert_equal(:zippy, @ie4.speed)
|
19
|
+
|
20
|
+
assert_raise(ArgumentError){@ie4.speed = :fubar}
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
@ie4.close if @ie4.exists?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class TC_class_options < Test::Unit::TestCase
|
29
|
+
tags :fails_on_firefox
|
30
|
+
include Watir
|
31
|
+
@@hide_ie = $HIDE_IE
|
32
|
+
def setup
|
33
|
+
@previous = IE.options
|
34
|
+
end
|
35
|
+
def test_class_defaults
|
36
|
+
assert_equal({:speed => IE.speed, :visible => IE.visible, :attach_timeout => IE.attach_timeout, :zero_based_indexing => IE.zero_based_indexing}, IE.options)
|
37
|
+
end
|
38
|
+
def test_change_defaults
|
39
|
+
IE.set_options(:speed => :fast)
|
40
|
+
assert_equal(:fast, IE.speed)
|
41
|
+
IE.set_options(:visible => false)
|
42
|
+
assert_equal(false, IE.visible)
|
43
|
+
IE.set_options(:speed => :slow)
|
44
|
+
assert_equal(:slow, IE.speed)
|
45
|
+
IE.set_options(:visible => true)
|
46
|
+
assert_equal(true, IE.visible)
|
47
|
+
IE.set_options(:attach_timeout => 22.0)
|
48
|
+
assert_equal(22.0, IE.attach_timeout)
|
49
|
+
end
|
50
|
+
def test_defaults_affect_on_instance
|
51
|
+
IE.set_options(:speed => :fast)
|
52
|
+
@ie1 = IE.new
|
53
|
+
assert_equal(:fast, @ie1.speed)
|
54
|
+
IE.set_options(:speed => :slow)
|
55
|
+
@ie2 = IE.new
|
56
|
+
assert_equal(:slow, @ie2.speed)
|
57
|
+
IE.set_options(:speed => :zippy)
|
58
|
+
@ie3 = IE.new
|
59
|
+
assert_equal(:zippy, @ie3.speed)
|
60
|
+
end
|
61
|
+
def teardown
|
62
|
+
IE.set_options @previous
|
63
|
+
@ie1.close if @ie1
|
64
|
+
@ie2.close if @ie2
|
65
|
+
@ie3.close if @ie3
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# feature tests for xpath table cells
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
4
|
+
require 'unittests/setup'
|
5
|
+
|
6
|
+
class TC_TableCell_XPath < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
goto_page "tableCell_using_xpath.html"
|
10
|
+
end
|
11
|
+
|
12
|
+
def testCellExists
|
13
|
+
# There is no <image> with @src='rectangle.jpg'. So image will not be there.
|
14
|
+
assert_false( browser.cell(:xpath , "//img[@src='images\/rectangle.jpg']/../").exists? )
|
15
|
+
# Select the parent element of image with src='square.jpg' which is a tablecell.
|
16
|
+
assert( browser.cell(:xpath , "//img[@src='images\/square.jpg']/../").exists? )
|
17
|
+
assert( browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").exists? )
|
18
|
+
puts "Selected table cell with text 'Table Cell with image of triangle.'"
|
19
|
+
puts browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
def testCell_properties
|
23
|
+
assert_equal(1 , browser.cell(:xpath , "//img[@src='images\/square.jpg']/../").colspan)
|
24
|
+
assert_equal(2 , browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").colspan)
|
25
|
+
assert_equal(3 , browser.cell(:xpath , "//img[@src='images\/circle.jpg']/../").colspan)
|
26
|
+
assert_equal(4 , browser.cell(:xpath , "//img[@src='images\/button.jpg']/../").colspan)
|
27
|
+
|
28
|
+
# to string tests -- output should be verified!
|
29
|
+
puts browser.cell(:xpath , "//img[@src='images\/square.jpg']/../").to_s
|
30
|
+
puts browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,296 @@
|
|
1
|
+
# feature tests for Tables
|
2
|
+
# Why do so many of these tests call "strip"? A distinct smell...
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Tables < Test::Unit::TestCase
|
8
|
+
include Watir::Exception
|
9
|
+
|
10
|
+
def setup
|
11
|
+
uses_page "table1.html"
|
12
|
+
end
|
13
|
+
def teardown
|
14
|
+
browser.refresh if @reload_page
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_exists
|
18
|
+
assert browser.table(:id, 't1').exists?
|
19
|
+
assert browser.table(:id, /t/).exists?
|
20
|
+
|
21
|
+
assert !browser.table(:id, 'missingTable').exists?
|
22
|
+
assert !browser.table(:id, /missing_table/).exists?
|
23
|
+
|
24
|
+
assert browser.table(:index, 0).exists?
|
25
|
+
assert !browser.table(:index, 33).exists?
|
26
|
+
end
|
27
|
+
|
28
|
+
tag_method :test_row_count_exceptions, :fails_on_firefox
|
29
|
+
def test_row_count_exceptions
|
30
|
+
assert_raises UnknownObjectException do
|
31
|
+
browser.table(:id, 'missingTable').row_count
|
32
|
+
end
|
33
|
+
assert_raises UnknownObjectException do
|
34
|
+
browser.table(:index, 66).row_count
|
35
|
+
end
|
36
|
+
assert_raises MissingWayOfFindingObjectException do
|
37
|
+
browser.table(:bad_attribute, 99).row_count
|
38
|
+
end
|
39
|
+
end
|
40
|
+
def test_rows
|
41
|
+
assert_equal(2, browser.table(:index, 0).row_count)
|
42
|
+
assert_equal(2, browser.table(:index, 0).rows.length)
|
43
|
+
|
44
|
+
assert_equal(5, browser.table(:id, 't1').row_count) # 4 rows and a header
|
45
|
+
assert_equal(5, browser.table(:index, 1).row_count) # same table as above, just accessed by index
|
46
|
+
assert_equal(5, browser.table(:id, 't1').rows.length)
|
47
|
+
|
48
|
+
# test the each iterator on rows - ie, go through each cell
|
49
|
+
row = browser.table(:index, 1)[1]
|
50
|
+
result = []
|
51
|
+
row.each do |cell|
|
52
|
+
result << cell.to_s.strip
|
53
|
+
end
|
54
|
+
assert_equal(['Row 1 Col1', 'Row 1 Col2'], result)
|
55
|
+
assert_equal(2, row.column_count)
|
56
|
+
end
|
57
|
+
|
58
|
+
tag_method :test_row_counts, :fails_on_firefox
|
59
|
+
def test_row_counts
|
60
|
+
table = browser.table(:id => 't2')
|
61
|
+
assert_equal(2, table.row_count)
|
62
|
+
end
|
63
|
+
|
64
|
+
tag_method :test_dynamic_tables, :fails_on_firefox
|
65
|
+
def test_dynamic_tables
|
66
|
+
@reload_page = true
|
67
|
+
t = browser.table(:id, 't1')
|
68
|
+
assert_equal(5, t.row_count)
|
69
|
+
browser.button(:value, 'add row').click
|
70
|
+
assert_equal(6, t.row_count)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_columns
|
74
|
+
assert_raises UnknownObjectException do
|
75
|
+
browser.table(:id, 'missingTable').column_count
|
76
|
+
end
|
77
|
+
assert_raises UnknownObjectException do
|
78
|
+
browser.table(:index, 77).column_count
|
79
|
+
end
|
80
|
+
assert_equal(2, browser.table(:index, 0).column_count)
|
81
|
+
assert_equal(1, browser.table(:id, 't1').column_count) # row one has 1 cell with a colspan of 2
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_links_and_images_in_table
|
85
|
+
table = browser.table(:id, 'pic_table')
|
86
|
+
image = table[0][1].image(:index,0)
|
87
|
+
assert_equal(106, image.width)
|
88
|
+
|
89
|
+
link = table[0][3].link(:index,0)
|
90
|
+
assert_equal("Google", link.text)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_cell_directly
|
94
|
+
assert browser.td(:id, 'cell1').exists?
|
95
|
+
assert ! browser.td(:id, 'no_exist').exists?
|
96
|
+
assert_equal("Row 1 Col1", browser.td(:id, 'cell1').to_s.strip)
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_cell_another_way
|
100
|
+
assert_equal( "Row 1 Col1", browser.table(:index,0)[0][0].to_s.strip)
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_row_directly
|
104
|
+
assert browser.tr(:id, 'row1').exists?
|
105
|
+
assert ! browser.tr(:id, 'no_exist').exists?
|
106
|
+
end
|
107
|
+
def test_row_another_way
|
108
|
+
assert_equal('Row 2 Col1', browser.tr(:id, 'row1')[0].to_s.strip)
|
109
|
+
end
|
110
|
+
|
111
|
+
tag_method :test_row_in_table, :fails_on_firefox
|
112
|
+
def test_row_in_table
|
113
|
+
assert_equal 'Row 2 Col1 Row 2 Col2',
|
114
|
+
browser.table(:id, 't1').row(:id, 'row1').text.gsub(/(\r|\n)/,'')
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_row_collection
|
118
|
+
t = browser.table(:index,0)
|
119
|
+
t.rows.each_with_index do |row, i|
|
120
|
+
assert("Row #{i + 1} Col1", row[0].text)
|
121
|
+
assert("Row #{i + 1} Col2", row[1].text)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
tag_method :test_cell_collection, :fails_on_firefox
|
126
|
+
def test_cell_collection
|
127
|
+
t = browser.table(:index,0)
|
128
|
+
contents = t.cells.collect {|c| c.text}
|
129
|
+
assert_equal(["Row 1 Col1","Row 1 Col2","Row 2 Col1","Row 2 Col2"], contents)
|
130
|
+
end
|
131
|
+
|
132
|
+
tag_method :test_table_body, :fails_on_firefox
|
133
|
+
def test_table_body
|
134
|
+
assert_equal(1, browser.table(:index, 0).tbodys.length)
|
135
|
+
assert_equal(3, browser.table(:id, 'body_test').tbodys.length)
|
136
|
+
|
137
|
+
count = 1
|
138
|
+
browser.table(:id, 'body_test').tbodys.each do |n|
|
139
|
+
# do something better here!
|
140
|
+
case count
|
141
|
+
when 1
|
142
|
+
compare_text = "This text is in the FRST TBODY."
|
143
|
+
when 2
|
144
|
+
compare_text = "This text is in the SECOND TBODY."
|
145
|
+
when 3
|
146
|
+
compare_text = "This text is in the THIRD TBODY."
|
147
|
+
end
|
148
|
+
assert_equal(compare_text, n[0][0].to_s.strip ) # this is the 1st cell of the first row of this particular body
|
149
|
+
count += 1
|
150
|
+
end
|
151
|
+
assert_equal( count - 1, browser.table(:id, 'body_test').tbodys.length )
|
152
|
+
assert_equal( "This text is in the THIRD TBODY." ,browser.table(:id, 'body_test' ).tbody(:index,2)[0][0].to_s.strip )
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_table_container
|
156
|
+
assert_nothing_raised { browser.table(:id, 't1').html }
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_multiple_selector
|
160
|
+
assert_equal('Second table with css class',
|
161
|
+
browser.table(:class => 'sample', :index => 1)[0][0].text)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
class TC_Tables_Simple < Test::Unit::TestCase
|
166
|
+
include Watir
|
167
|
+
|
168
|
+
def setup
|
169
|
+
goto_page "simple_table.html"
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_simple_table_access
|
173
|
+
table = browser.table(:index,0)
|
174
|
+
assert_equal("Row 3 Col1", table[2][0].text.strip)
|
175
|
+
assert_equal("Row 1 Col1", table[0][0].text.strip)
|
176
|
+
assert_equal("Row 3 Col2", table[2][1].text.strip)
|
177
|
+
assert_equal(2, table.column_count)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
class TC_Tables_Buttons < Test::Unit::TestCase
|
181
|
+
include Watir
|
182
|
+
|
183
|
+
def setup
|
184
|
+
uses_page "simple_table_buttons.html"
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_simple_table_buttons
|
188
|
+
table = browser.table(:index, 0)
|
189
|
+
|
190
|
+
table[0][0].button(:index, 0).click
|
191
|
+
assert(browser.text_field(:name,"confirmtext").verify_contains(/CLICK1/i))
|
192
|
+
table[1][0].button(:index, 0).click
|
193
|
+
assert(browser.text_field(:name,"confirmtext").verify_contains(/CLICK2/i))
|
194
|
+
|
195
|
+
table[0][0].button(:id, 'b1').click
|
196
|
+
assert(browser.text_field(:name,"confirmtext").verify_contains(/CLICK1/i))
|
197
|
+
|
198
|
+
assert_raises(UnknownObjectException ) { table[0][0].button(:id,'b_missing').click }
|
199
|
+
|
200
|
+
table[2][0].button(:index, 1).click
|
201
|
+
assert(browser.text_field(:name,"confirmtext").verify_contains(/TOO/i))
|
202
|
+
|
203
|
+
table[2][0].button(:value, "Click too").click
|
204
|
+
assert(browser.text_field(:name,"confirmtext").verify_contains(/TOO/i))
|
205
|
+
|
206
|
+
browser.table(:index, 0)[3][0].text_field(:index,0).set("123")
|
207
|
+
assert(browser.text_field(:index,1).verify_contains("123"))
|
208
|
+
|
209
|
+
# check when a cell contains 2 objects
|
210
|
+
|
211
|
+
# if there were 2 different html objects in the same cell, some weird things happened ( button caption could change for example)
|
212
|
+
assert_equal( 'Click ->' , browser.table(:index,0)[4][0].text_field(:index,0).value )
|
213
|
+
browser.table(:index,0)[4][0].text_field(:index,0).click
|
214
|
+
assert_equal( 'Click ->' , browser.table(:index,0)[4][0].text_field(:index,0).value )
|
215
|
+
|
216
|
+
browser.table(:index,0)[4][0].button(:index,0).click
|
217
|
+
assert_equal( '' , browser.table(:index,0)[4][0].text_field(:index,0).value )
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_simple_table_gif
|
221
|
+
table = browser.table(:index,1)
|
222
|
+
assert_match(/1\.gif/, table[0][0].image(:index, 0).src)
|
223
|
+
assert_match(/2\.gif/, table[0][1].image(:index, 0).src)
|
224
|
+
assert_match(/3\.gif/, table[0][2].image(:index, 0).src)
|
225
|
+
|
226
|
+
assert_match(/1\.gif/, table[2][0].image(:index, 0).src)
|
227
|
+
assert_match(/2\.gif/, table[2][1].image(:index, 0).src)
|
228
|
+
assert_match(/3\.gif/, table[2][2].image(:index, 0).src)
|
229
|
+
|
230
|
+
table = browser.table(:index,2)
|
231
|
+
assert_match(/1\.gif/, table[0][0].image(:index, 0).src)
|
232
|
+
assert_match(/2\.gif/, table[0][0].image(:index, 1).src)
|
233
|
+
assert_match(/3\.gif/, table[0][0].image(:index, 2).src)
|
234
|
+
|
235
|
+
assert_match(/1\.gif/, table[2][0].image(:index, 0).src)
|
236
|
+
assert_match(/2\.gif/, table[2][0].image(:index, 1).src)
|
237
|
+
assert_match(/3\.gif/, table[2][0].image(:index, 2).src)
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
class TC_Table_Columns < Test::Unit::TestCase
|
243
|
+
include Watir::Exception
|
244
|
+
def setup
|
245
|
+
uses_page "simple_table_columns.html"
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_get_columnvalues_single_column
|
249
|
+
assert_equal(["R1C1", "R2C1", "R3C1"], browser.table(:index, 0).column_values(0))
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_colspan
|
253
|
+
assert_equal(2, browser.table(:index, 2)[1][0].colspan)
|
254
|
+
assert_equal(1, browser.table(:index, 2)[0][0].colspan)
|
255
|
+
assert_equal(3, browser.table(:index, 2)[3][0].colspan)
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_get_columnvalues_multiple_column
|
259
|
+
assert_equal(["R1C1", "R2C1", "R3C1"], browser.table(:index, 1).column_values(0))
|
260
|
+
assert_equal(["R1C3", "R2C3", "R3C3"], browser.table(:index, 1).column_values(2))
|
261
|
+
end
|
262
|
+
|
263
|
+
tag_method :test_get_columnvalues_with_colspan, :fails_on_firefox
|
264
|
+
def test_get_columnvalues_with_colspan
|
265
|
+
assert_equal(["R1C1", "R2C1", "R3C1", "R4C1", "R5C1", "R6C2"], browser.table(:index, 2).column_values(0))
|
266
|
+
(1..3).each{|x|assert_raises(UnknownCellException){browser.table(:index, 2).column_values(x)}}
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_get_rowvalues_full_row
|
270
|
+
assert_equal(["R1C1", "R1C2", "R1C3"], browser.table(:index, 2).row_values(0))
|
271
|
+
end
|
272
|
+
|
273
|
+
def test_get_rowvalues_with_colspan
|
274
|
+
assert_equal(["R2C1", "R2C2"], browser.table(:index, 2).row_values(1))
|
275
|
+
end
|
276
|
+
|
277
|
+
def test_getrowvalues_with_rowspan
|
278
|
+
assert_equal(["R5C1", "R5C2", "R5C3"], browser.table(:index, 2).row_values(4))
|
279
|
+
assert_equal(["R6C2", "R6C3"], browser.table(:index, 2).row_values(5))
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
class TC_Tables_Complex < Test::Unit::TestCase
|
284
|
+
def setup
|
285
|
+
uses_page "complex_table.html"
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_complex_table_access
|
289
|
+
table = browser.table(:index,0)
|
290
|
+
assert_equal("subtable1 Row 1 Col1",table[0][0].table(:index,0)[0][0].text.strip)
|
291
|
+
assert_equal("subtable1 Row 1 Col2",table[0][0].table(:index,0)[0][1].text.strip)
|
292
|
+
assert_equal("subtable2 Row 1 Col2",table[1][0].table(:index,0)[0][1].text.strip)
|
293
|
+
assert_equal("subtable2 Row 1 Col1",table[1][0].table(:index,0)[0][0].text.strip)
|
294
|
+
end
|
295
|
+
|
296
|
+
end
|