watir 1.4.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/watir-console +1 -0
- data/changes.rb +119 -0
- data/license.rb +37 -0
- data/readme.rb +55 -120
- data/unittests/buttons_test.rb +107 -104
- data/unittests/buttons_xpath_test.rb +69 -0
- data/unittests/checkbox_test.rb +154 -141
- data/unittests/checkbox_xpath_test.rb +107 -0
- data/unittests/core_tests.rb +6 -2
- data/unittests/css_test.rb +50 -50
- data/unittests/defer_test.rb +47 -0
- data/unittests/dialog_test.rb +78 -0
- data/unittests/div2_xpath_test.rb +22 -0
- data/unittests/div_test.rb +159 -159
- data/unittests/div_xpath_test.rb +96 -0
- data/unittests/errorchecker_test.rb +22 -22
- data/unittests/filefield_test.rb +30 -23
- data/unittests/filefield_xpath_test.rb +35 -0
- data/unittests/form_test.rb +250 -229
- data/unittests/form_xpath_test.rb +253 -0
- data/unittests/frame_test.rb +123 -108
- data/unittests/google_form_test.rb +17 -0
- data/unittests/html/JavascriptClick.html +39 -0
- data/unittests/html/buttons1.html +3 -2
- data/unittests/html/checkboxes1.html +32 -14
- data/unittests/html/complex_table.html +1 -1
- data/unittests/html/depot_store.html +59 -0
- data/unittests/html/div.html +3 -21
- data/unittests/html/div_xml.html +21 -0
- data/unittests/html/fileupload.html +2 -2
- data/unittests/html/forms2.html +3 -3
- data/unittests/html/forms3.html +2 -2
- data/unittests/html/frame_links.html +2 -2
- data/unittests/html/google_india.html +119 -0
- data/unittests/html/iframeTest.html +2 -2
- data/unittests/html/images/map.GIF +0 -0
- data/unittests/html/images/map2.gif +0 -0
- data/unittests/html/images1.html +17 -2
- data/unittests/html/javascriptevents.html +3 -7
- data/unittests/html/links1.html +9 -8
- data/unittests/html/links_multi.html +14 -0
- data/unittests/html/list_matters.html +720 -0
- data/unittests/html/lists.html +18 -0
- data/unittests/html/map_test.html +31 -0
- data/unittests/html/modal_dialog.html +10 -0
- data/unittests/html/modal_dialog_launcher.html +12 -0
- data/unittests/html/new_browser.html +17 -0
- data/unittests/html/pass.html +3 -0
- data/unittests/html/popups1.html +1 -1
- data/unittests/html/pre.html +28 -0
- data/unittests/html/radioButtons1.html +6 -5
- data/unittests/html/selectboxes1.html +12 -11
- data/unittests/html/simple_table.html +1 -1
- data/unittests/html/simple_table_columns.html +1 -1
- data/unittests/html/table1.html +1 -1
- data/unittests/html/tableCell_using_xpath.html +19 -0
- data/unittests/html/textfields1.html +6 -4
- data/unittests/html/xpath_nbsp.html +12 -0
- data/unittests/ie_exists_test.rb +32 -0
- data/unittests/ie_mock.rb +78 -79
- data/unittests/ie_test.rb +39 -39
- data/unittests/images_test.rb +132 -155
- data/unittests/images_xpath_test.rb +91 -0
- data/unittests/links_multi_test.rb +36 -0
- data/unittests/links_test.rb +158 -152
- data/unittests/links_xpath_test.rb +40 -0
- data/unittests/lists_test.rb +29 -0
- data/unittests/map_test.rb +99 -0
- data/unittests/minmax_test.rb +23 -23
- data/unittests/navigate_test.rb +43 -51
- data/unittests/nbsp_xpath_test.rb +18 -0
- data/unittests/other/WindowLogonExample.rb +28 -0
- data/unittests/{WindowLogonExtra.rb → other/WindowLogonExtra.rb} +0 -0
- data/unittests/{all_tests_concurrent.rb → other/all_tests_concurrent.rb} +23 -23
- data/unittests/other/navigate_exception_test.rb +14 -0
- data/unittests/other/rexml_unit_test.rb +24 -0
- data/unittests/other/testcase_method_order_test.rb +36 -0
- data/unittests/other/testcase_verify_test.rb +25 -0
- data/unittests/other/wait_until_test.rb +99 -0
- data/unittests/pagecontainstext_test.rb +56 -37
- data/unittests/parent_child_test.rb +55 -0
- data/unittests/popups_test.rb +37 -37
- data/unittests/pre_test.rb +52 -0
- data/unittests/radios_test.rb +186 -155
- data/unittests/radios_xpath_test.rb +101 -0
- data/unittests/screen_capture_test.rb +41 -41
- data/unittests/selectbox_test.rb +223 -181
- data/unittests/selectbox_xpath_test.rb +113 -0
- data/unittests/setup.rb +29 -25
- data/unittests/speed_settings_test.rb +22 -0
- data/unittests/table_cell_using_xpath_test.rb +40 -0
- data/unittests/table_test.rb +315 -284
- data/unittests/table_xpath_test.rb +114 -0
- data/unittests/textarea_test.rb +81 -0
- data/unittests/textarea_xpath_test.rb +82 -0
- data/unittests/textfields_test.rb +205 -229
- data/unittests/textfields_xpath_test.rb +111 -0
- data/unittests/window_tests.rb +7 -0
- data/unittests/windows/attach_to_existing_window_test.rb +52 -0
- data/unittests/windows/attach_to_new_window_test.rb +82 -0
- data/unittests/windows/close_window_test.rb +22 -0
- data/unittests/windows/frame_links_test.rb +25 -0
- data/unittests/windows/ie-each_test.rb +48 -0
- data/unittests/windows/iedialog_test.rb +55 -0
- data/unittests/windows/js_events_test.rb +57 -0
- data/unittests/windows/jscriptExtraAlert.rb +6 -0
- data/unittests/windows/jscriptExtraConfirmCancel.rb +7 -0
- data/unittests/windows/jscriptExtraConfirmOk.rb +7 -0
- data/unittests/{jscriptPushButton.rb → windows/jscriptPushButton.rb} +1 -1
- data/unittests/windows/jscript_test.rb +64 -0
- data/unittests/windows/modal_dialog_test.rb +127 -0
- data/unittests/windows/new.rb +56 -0
- data/unittests/windows/open_close_test.rb +22 -0
- data/unittests/windows/send_keys_test.rb +34 -0
- data/unittests/xpath_tests.rb +10 -0
- data/watir.rb +4344 -3565
- data/watir/IEDialog/Release/IEDialog.dll +0 -0
- data/watir/WindowHelper.rb +13 -11
- data/watir/assertions.rb +36 -0
- data/watir/camel_case.rb +14 -5
- data/watir/close_all.rb +38 -0
- data/watir/contrib/enabled_popup.rb +21 -0
- data/watir/contrib/ie-new-process.rb +27 -0
- data/watir/contrib/page_checker.rb +29 -0
- data/watir/contrib/visible.rb +47 -0
- data/watir/cookiemanager.rb +4 -4
- data/watir/datahandler.rb +107 -0
- data/watir/dialog.rb +46 -0
- data/watir/elements.rb +65 -0
- data/watir/exceptions.rb +18 -36
- data/watir/ie-process.rb +40 -0
- data/watir/irb-history.rb +31 -0
- data/watir/process.rb +20 -0
- data/watir/testUnitAddons.rb +3 -42
- data/watir/testcase.rb +58 -0
- data/watir/utils.rb +20 -0
- data/watir/waiter.rb +88 -0
- data/watir/watir_simple.rb +4 -4
- data/watir/win32ole.rb +8 -0
- data/watir/win32ole/win32ole.so +0 -0
- data/watir/winClicker.rb +374 -400
- metadata +209 -128
- data/unittests/WindowLogonExample.rb +0 -30
- data/unittests/attachToExistingWindow_test.rb +0 -40
- data/unittests/js_events_test.rb +0 -77
- data/unittests/jscriptExtraAlert.rb +0 -6
- data/unittests/jscriptExtraConfirmCancel.rb +0 -7
- data/unittests/jscriptExtraConfirmOk.rb +0 -7
- data/unittests/jscript_test.rb +0 -57
- data/unittests/send_keys_test.rb +0 -29
- data/unittests/textAreafields_test.rb +0 -81
@@ -0,0 +1,113 @@
|
|
1
|
+
# feature tests for Select Boxes
|
2
|
+
# revision: $Revision: 962 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Selectbox_XPath < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
$ie.goto($htmlRoot + "selectboxes1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_textBox_Exists
|
15
|
+
assert($ie.select_list(:xpath, "//select[@name='sel1']/").exists?)
|
16
|
+
assert(!$ie.select_list(:xpath, "//select[@name='missing']/").exists?)
|
17
|
+
assert(!$ie.select_list(:xpath, "//select[@id='missing']/").exists?)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_select_list_enabled
|
21
|
+
assert($ie.select_list(:xpath, "//select[@name='sel1']/").enabled?)
|
22
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").enabled? }
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_select_list_getAllContents
|
26
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").getAllContents }
|
27
|
+
assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
|
28
|
+
$ie.select_list(:xpath, "//select[@name='sel1']/").getAllContents)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_select_list_getSelectedItems
|
32
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
|
33
|
+
assert_equal( ["Option 3" ] ,
|
34
|
+
$ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
|
35
|
+
assert_equal( ["Option 3" , "Option 6" ] ,
|
36
|
+
$ie.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_clearSelection
|
40
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").clearSelection }
|
41
|
+
$ie.select_list(:xpath, "//select[@name='sel1']/").clearSelection
|
42
|
+
|
43
|
+
# the box sel1 has no ability to have a de-selected item
|
44
|
+
assert_equal( ["Option 3" ] , $ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
|
45
|
+
|
46
|
+
$ie.select_list(:xpath, "//select[@name='sel2']/").clearSelection
|
47
|
+
assert_equal( [ ] , $ie.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_select_list_select
|
51
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
|
52
|
+
assert_raises(NoValueFoundException) { $ie.select_list(:xpath, "//select[@name='sel1']/").select("missing item") }
|
53
|
+
assert_raises(NoValueFoundException) { $ie.select_list(:xpath, "//select[@name='sel1']/").select(/missing/) }
|
54
|
+
|
55
|
+
# the select method keeps any currently selected items - use the clear selectcion method first
|
56
|
+
$ie.select_list(:xpath, "//select[@name='sel1']/").clearSelection
|
57
|
+
$ie.select_list(:xpath, "//select[@name='sel1']/").select("Option 1")
|
58
|
+
assert_equal( ["Option 1" ] , $ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
|
59
|
+
|
60
|
+
$ie.select_list(:xpath, "//select[@name='sel1']/").clearSelection
|
61
|
+
$ie.select_list(:xpath, "//select[@name='sel1']/").select(/2/)
|
62
|
+
assert_equal( ["Option 2" ] , $ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
|
63
|
+
|
64
|
+
$ie.select_list(:xpath, "//select[@name='sel2']/").clearSelection
|
65
|
+
$ie.select_list(:xpath, "//select[@name='sel2']/").select( /2/ )
|
66
|
+
$ie.select_list(:xpath, "//select[@name='sel2']/").select( /4/ )
|
67
|
+
assert_equal( ["Option 2" , "Option 4" ] ,
|
68
|
+
$ie.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
|
69
|
+
|
70
|
+
# these are to test the onchange event
|
71
|
+
# the event shouldnt get fired, as this is the selected item
|
72
|
+
$ie.select_list(:xpath, "//select[@name='sel3']/").select( /3/ )
|
73
|
+
assert(!$ie.text.include?("Pass") )
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_select_list_select2
|
77
|
+
# the event should get fired
|
78
|
+
$ie.select_list(:xpath, "//select[@name='sel3']/").select( /2/ )
|
79
|
+
assert($ie.text.include?("PASS") )
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_select_list_select_using_value
|
83
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
|
84
|
+
assert_raises(NoValueFoundException) { $ie.select_list(:xpath, "//select[@name='sel1']/").select_value("missing item") }
|
85
|
+
assert_raises(NoValueFoundException) { $ie.select_list(:xpath, "//select[@name='sel1']/").select_value(/missing/) }
|
86
|
+
|
87
|
+
# the select method keeps any currently selected items - use the clear selectcion method first
|
88
|
+
$ie.select_list(:xpath, "//select[@name='sel1']/").clearSelection
|
89
|
+
$ie.select_list(:xpath, "//select[@name='sel1']/").select_value("o1")
|
90
|
+
assert_equal( ["Option 1" ] , $ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
|
91
|
+
|
92
|
+
$ie.select_list(:xpath, "//select[@name='sel1']/").clearSelection
|
93
|
+
$ie.select_list(:xpath, "//select[@name='sel1']/").select_value(/2/)
|
94
|
+
assert_equal( ["Option 2" ] , $ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
|
95
|
+
|
96
|
+
$ie.select_list(:xpath, "//select[@name='sel2']/").clearSelection
|
97
|
+
$ie.select_list(:xpath, "//select[@name='sel2']/").select( /2/ )
|
98
|
+
$ie.select_list(:xpath, "//select[@name='sel2']/").select( /4/ )
|
99
|
+
assert_equal( ["Option 2" , "Option 4" ] , $ie.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
|
100
|
+
|
101
|
+
# these are to test the onchange event
|
102
|
+
# the event shouldnt get fired, as this is the selected item
|
103
|
+
$ie.select_list(:xpath, "//select[@name='sel3']/").select_value( /3/ )
|
104
|
+
assert(!$ie.text.include?("Pass") )
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_select_list_select_using_value2
|
108
|
+
# the event should get fired
|
109
|
+
$ie.select_list(:xpath, "//select[@name='sel3']/").select_value( /2/ )
|
110
|
+
assert($ie.text.include?("PASS") )
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
data/unittests/setup.rb
CHANGED
@@ -1,47 +1,51 @@
|
|
1
|
-
END {$ie.close if $ie} # close ie at completion of the tests
|
2
|
-
|
3
1
|
# libraries used by feature tests
|
4
2
|
require 'watir'
|
3
|
+
END {$ie.close if $ie && $ie.exists?; Watir::IE.quit} # close ie at completion of the tests
|
4
|
+
|
5
5
|
require 'test/unit'
|
6
6
|
require 'test/unit/ui/console/testrunner'
|
7
7
|
require 'watir/testUnitAddons'
|
8
|
+
require 'watir/testcase'
|
8
9
|
|
9
10
|
topdir = File.join(File.dirname(__FILE__), '..')
|
10
11
|
Dir.chdir topdir do
|
11
12
|
$all_tests = Dir["unittests/*_test.rb"]
|
13
|
+
$xpath_tests = Dir["unittests/*_xpath_test.rb"]
|
12
14
|
end
|
13
15
|
|
16
|
+
$window_tests =
|
17
|
+
['js_events', # is always visible
|
18
|
+
'modal_dialog', # modal is visible
|
19
|
+
'attach_to_existing_window', # could actually run robustly as part of the core suite!
|
20
|
+
'attach_to_new_window', # creates new window
|
21
|
+
'jscript',
|
22
|
+
'send_keys', # visible
|
23
|
+
'iedialog', # visible
|
24
|
+
'close_window', # creates new window
|
25
|
+
'frame_links', # visible
|
26
|
+
'open_close',
|
27
|
+
].collect {|x| "unittests/windows/#{x}_test.rb"}
|
28
|
+
|
14
29
|
$non_core_tests =
|
15
30
|
['popups', # has problems when run in a suite (is ok when run alone);
|
16
31
|
# must be visible
|
17
32
|
# will be revised to use autoit
|
18
33
|
# takes 15 seconds to run
|
19
|
-
'images', #
|
20
|
-
'screen_capture', # is always visible; takes 25
|
34
|
+
'images', # save file must must be visible
|
35
|
+
'screen_capture', # is always visible; takes 25 seconds
|
21
36
|
'filefield', # is always visible; takes 40 seconds
|
22
|
-
'jscript',
|
23
|
-
'js_events', # is always visible
|
24
37
|
'minmax', # becomes visible
|
25
|
-
'
|
38
|
+
'dialog' # visible
|
26
39
|
].collect {|x| "unittests/#{x}_test.rb"}
|
27
40
|
|
28
|
-
$core_tests = $all_tests - $non_core_tests
|
29
|
-
|
30
|
-
def start_ie_with_logger
|
31
|
-
$ie = Watir::IE.new()
|
32
|
-
# $ie.logger = Watir::WatirLogger.new( 'debug.txt', 4, 10000 )
|
33
|
-
$ie.set_fast_speed
|
34
|
-
end
|
35
|
-
|
36
|
-
def set_local_dir
|
37
|
-
$myDir = File.expand_path(File.dirname(__FILE__))
|
38
|
-
$myDir.sub!( %r{/cygdrive/(\w)/}, '\1:/' ) # convert from cygwin to dos
|
39
|
-
# if you run the unit tests form a local file system use this line
|
40
|
-
$htmlRoot = "file://#{$myDir}/html/"
|
41
|
-
# if you run the unit tests from a web server use this line
|
42
|
-
# $htmlRoot = "http://localhost:8080/watir/html/"
|
43
|
-
end
|
41
|
+
$core_tests = $all_tests - $non_core_tests - $window_tests - $xpath_tests
|
44
42
|
|
45
|
-
|
46
|
-
|
43
|
+
$ie = Watir::IE.new
|
44
|
+
$ie.set_fast_speed
|
47
45
|
|
46
|
+
$myDir = File.expand_path(File.dirname(__FILE__))
|
47
|
+
$myDir.sub!( %r{/cygdrive/(\w)/}, '\1:/' ) # convert from cygwin to dos
|
48
|
+
# if you run the unit tests form a local file system use this line
|
49
|
+
$htmlRoot = "file://#{$myDir}/html/"
|
50
|
+
# if you run the unit tests from a web server use this line
|
51
|
+
# $htmlRoot = "http://localhost:8080/watir/html/"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# tests for ability to set defaults for Watir
|
2
|
+
# revision: $Revision: 958 $
|
3
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
4
|
+
require 'test/unit'
|
5
|
+
require 'watir'
|
6
|
+
|
7
|
+
class TC_Defaults < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def test_using_default
|
11
|
+
@ie1 = IE.new
|
12
|
+
@ie1.speed = :fast
|
13
|
+
assert_equal(:fast, @ie1.speed)
|
14
|
+
@ie1.speed = :slow
|
15
|
+
assert_equal(:slow, @ie1.speed)
|
16
|
+
assert_raise(ArgumentError){@ie1.speed = :fubar}
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
@ie1.close if @ie1
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# feature tests for xpath table cells
|
2
|
+
# revision: $Revision: 962 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_TableCell_XPath < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
gotoTableCellPage
|
12
|
+
end
|
13
|
+
|
14
|
+
def gotoTableCellPage
|
15
|
+
$ie.goto($htmlRoot + "tableCell_using_xpath.html")
|
16
|
+
end
|
17
|
+
|
18
|
+
def testCellExists
|
19
|
+
# There is no <image> with @src='rectangle.jpg'. So image will not be there.
|
20
|
+
assert(! $ie.cell(:xpath , "//img[@src='images\/rectangle.jpg']/../").exists? )
|
21
|
+
# Select the parent element of image with src='square.jpg' which is a tablecell.
|
22
|
+
assert( $ie.cell(:xpath , "//img[@src='images\/square.jpg']/../").exists? )
|
23
|
+
assert( $ie.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").exists? )
|
24
|
+
puts "Selected table cell with text 'Table Cell with image of triangle.'"
|
25
|
+
puts $ie.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
def testCell_properties
|
29
|
+
assert_equal(1 , $ie.cell(:xpath , "//img[@src='images\/square.jpg']/../").colspan)
|
30
|
+
assert_equal(2 , $ie.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").colspan)
|
31
|
+
assert_equal(3 , $ie.cell(:xpath , "//img[@src='images\/circle.jpg']/../").colspan)
|
32
|
+
assert_equal(4 , $ie.cell(:xpath , "//img[@src='images\/button.jpg']/../").colspan)
|
33
|
+
|
34
|
+
# to string tests -- output should be verified!
|
35
|
+
puts $ie.cell(:xpath , "//img[@src='images\/square.jpg']/../").to_s
|
36
|
+
puts $ie.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
data/unittests/table_test.rb
CHANGED
@@ -1,306 +1,337 @@
|
|
1
1
|
# feature tests for Tables
|
2
|
-
# revision: $Revision:
|
2
|
+
# revision: $Revision: 1076 $
|
3
3
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_Tables < Test::Unit::TestCase
|
8
|
-
|
9
|
-
|
10
|
-
def setup
|
11
|
-
gotoTablePage
|
12
|
-
end
|
13
|
-
|
14
|
-
def gotoTablePage()
|
15
|
-
$ie.goto($htmlRoot + "table1.html")
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_Table_Exists
|
19
|
-
assert_false($ie.table(:id , 'missingTable').exists? )
|
20
|
-
assert_false($ie.table(:index, 33).exists? )
|
21
|
-
|
22
|
-
assert($ie.table(:id, 't1').exists? )
|
23
|
-
assert($ie.table(:id, /t/).exists? )
|
24
|
-
assert_false($ie.table(:id , /missing_table/).exists? )
|
25
|
-
|
26
|
-
|
27
|
-
assert($ie.table(:index, 1).exists? )
|
28
|
-
assert($ie.table(:index, 2).exists? )
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_rows
|
32
|
-
assert_raises( UnknownTableException ){ $ie.table(:id , 'missingTable').row_count }
|
33
|
-
assert_raises( UnknownTableException ){ $ie.table(:index , 66).row_count }
|
34
|
-
|
35
|
-
assert_equal( 2 , $ie.table(:index , 1).row_count)
|
36
|
-
assert_equal( 5 , $ie.table(:id, 't1').row_count) # 4 rows and a header
|
37
|
-
assert_equal( 5 , $ie.table(:index, 2).row_count) # same table as above, just accessed by index
|
38
|
-
|
39
|
-
# test the each iterator on rows - ie, go through each cell
|
40
|
-
row = $ie.table(:index, 2)[2]
|
41
|
-
count=1
|
42
|
-
row.each do |cell|
|
43
|
-
# cell.flash # this line commented out to speed up the test
|
44
|
-
if count == 1
|
45
|
-
assert_equal('Row 1 Col1' , cell.to_s.strip )
|
46
|
-
elsif count==2
|
47
|
-
assert_equal('Row 1 Col2' , cell.to_s.strip )
|
48
|
-
end
|
49
|
-
count+=1
|
50
|
-
end
|
51
|
-
assert_equal(2, count -1)
|
52
|
-
assert_equal(2, $ie.table(:index, 2)[2].column_count)
|
53
|
-
end
|
8
|
+
include Watir
|
54
9
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
def test_columns
|
64
|
-
|
65
|
-
assert_raises( UnknownTableException ){ $ie.table(:id , 'missingTable').column_count }
|
66
|
-
assert_raises( UnknownTableException ){ $ie.table(:index , 77).column_count }
|
67
|
-
assert_equal( 2 , $ie.table(:index , 1).column_count)
|
68
|
-
assert_equal( 1 , $ie.table(:id, 't1').column_count) # row one has 1 cell with a colspan of 2
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_to_a
|
72
|
-
table1Expected = [ ["Row 1 Col1" , "Row 1 Col2"] ,[ "Row 2 Col1" , "Row 2 Col2"] ]
|
73
|
-
assert_arrayEquals(table1Expected, $ie.table(:index , 1).to_a )
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_simple_table_access
|
77
|
-
$ie.goto($htmlRoot + "simple_table.html")
|
78
|
-
|
79
|
-
table = $ie.table(:index,1)
|
10
|
+
def setup
|
11
|
+
$ie.goto($htmlRoot + "table1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_Table_Exists
|
15
|
+
assert(!$ie.table(:id, 'missingTable').exists?)
|
16
|
+
assert(!$ie.table(:index, 33).exists?)
|
80
17
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
18
|
+
assert($ie.table(:id, 't1').exists?)
|
19
|
+
assert($ie.table(:id, /t/).exists?)
|
20
|
+
assert(!$ie.table(:id, /missing_table/).exists?)
|
21
|
+
|
22
|
+
assert($ie.table(:index, 1).exists?)
|
23
|
+
assert($ie.table(:index, 2).exists?)
|
24
|
+
end
|
86
25
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
# check when a cell contains 2 objects
|
112
|
-
|
113
|
-
# if there were 2 different html objects in the same cell, some weird things happened ( button caption could change for example)
|
114
|
-
assert_equal( 'Click ->' , $ie.table(:index,1)[5][1].text_field(:index,1).value )
|
115
|
-
$ie.table(:index,1)[5][1].text_field(:index,1).click
|
116
|
-
assert_equal( 'Click ->' , $ie.table(:index,1)[5][1].text_field(:index,1).value )
|
117
|
-
|
118
|
-
$ie.table(:index,1)[5][1].button(:index,1).click
|
119
|
-
assert_equal( '' , $ie.table(:index,1)[5][1].text_field(:index,1).value )
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_simple_table_gif
|
123
|
-
$ie.goto($htmlRoot + "simple_table_buttons.html")
|
124
|
-
|
125
|
-
table = $ie.table(:index,2)
|
126
|
-
|
127
|
-
assert_match( /1\.gif/ , table[1][1].image( :index,1).src )
|
128
|
-
assert_match( /2\.gif/ , table[1][2].image( :index ,1).src )
|
129
|
-
assert_match( /3\.gif/ , table[1][3].image( :index ,1).src )
|
130
|
-
|
131
|
-
assert_match( /1\.gif/ , table[3][1].image( :index ,1).src )
|
132
|
-
assert_match( /2\.gif/ , table[3][2].image( :index ,1).src )
|
133
|
-
assert_match( /3\.gif/ , table[3][3].image( :index ,1).src )
|
134
|
-
|
135
|
-
table = $ie.table(:index,3)
|
136
|
-
assert_match( /1\.gif/ , table[1][1].image( :index ,1).src )
|
137
|
-
assert_match( /2\.gif/ , table[1][1].image( :index ,2).src )
|
138
|
-
assert_match( /3\.gif/ , table[1][1].image( :index ,3).src )
|
139
|
-
|
140
|
-
assert_match( /1\.gif/ , table[3][1].image( :index ,1).src )
|
141
|
-
assert_match( /2\.gif/ , table[3][1].image( :index ,2).src )
|
142
|
-
assert_match( /3\.gif/ , table[3][1].image( :index ,3).src )
|
143
|
-
end
|
144
|
-
|
145
|
-
def test_table_with_hidden_or_visible_rows
|
146
|
-
$ie.goto($htmlRoot + "simple_table_buttons.html")
|
147
|
-
t = $ie.table(:id , 'show_hide')
|
148
|
-
|
149
|
-
# expand the table
|
150
|
-
t.each do |r|
|
151
|
-
r[1].image(:src, /plus/).click if r[1].image(:src, /plus/).exists?
|
152
|
-
end
|
153
|
-
|
154
|
-
# shrink rows 1,2,3
|
155
|
-
count=1
|
156
|
-
t.each do |r|
|
157
|
-
r[1].image(:src, /minus/).click if r[1].image(:src, /minus/).exists? and (1..3) === count
|
158
|
-
count=2
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_links_and_images_in_table
|
163
|
-
table = $ie.table(:id, 'pic_table')
|
164
|
-
image = table[1][2].image(:index,1)
|
165
|
-
assert_equal("106", image.width)
|
166
|
-
|
167
|
-
link = table[1][4].link(:index,1)
|
168
|
-
assert_equal("Google", link.innerText)
|
169
|
-
end
|
170
|
-
|
171
|
-
def test_table_from_element
|
172
|
-
$ie.goto($htmlRoot + "simple_table_buttons.html")
|
173
|
-
|
174
|
-
button = $ie.button(:id,"b1")
|
175
|
-
table = Table.create_from_element($ie,button)
|
176
|
-
|
177
|
-
table[2][1].button(:index,1).click
|
178
|
-
assert($ie.textField(:name,"confirmtext").verify_contains(/CLICK2/i))
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_complex_table_access
|
182
|
-
$ie.goto($htmlRoot + "complex_table.html")
|
183
|
-
|
184
|
-
table = $ie.table(:index,1)
|
185
|
-
|
186
|
-
assert_equal("subtable1 Row 1 Col1",table[1][1].table(:index,1)[1][1].text.strip)
|
187
|
-
assert_equal("subtable1 Row 1 Col2",table[1][1].table(:index,1)[1][2].text.strip)
|
188
|
-
assert_equal("subtable2 Row 1 Col2",table[2][1].table(:index,1)[1][2].text.strip)
|
189
|
-
assert_equal("subtable2 Row 1 Col1",table[2][1].table(:index,1)[1][1].text.strip)
|
26
|
+
def test_rows
|
27
|
+
assert_raises(UnknownObjectException ){ $ie.table(:id, 'missingTable').row_count }
|
28
|
+
assert_raises(UnknownObjectException ){ $ie.table(:index, 66).row_count }
|
29
|
+
assert_raises(MissingWayOfFindingObjectException){ $ie.table(:bad_attribute, 99).row_count }
|
30
|
+
|
31
|
+
assert_equal(2, $ie.table(:index, 1).row_count)
|
32
|
+
assert_equal(2, $ie.table(:index, 1).rows.length)
|
33
|
+
|
34
|
+
assert_equal(5, $ie.table(:id, 't1').row_count) # 4 rows and a header
|
35
|
+
assert_equal(5, $ie.table(:index, 2).row_count) # same table as above, just accessed by index
|
36
|
+
assert_equal(5, $ie.table(:id, 't1').rows.length)
|
37
|
+
|
38
|
+
# test the each iterator on rows - ie, go through each cell
|
39
|
+
row = $ie.table(:index, 2)[2]
|
40
|
+
count = 1
|
41
|
+
row.each do |cell|
|
42
|
+
# cell.flash # this line commented out to speed up the test
|
43
|
+
if count == 1
|
44
|
+
assert_equal('Row 1 Col1', cell.to_s.strip)
|
45
|
+
elsif count==2
|
46
|
+
assert_equal('Row 1 Col2', cell.to_s.strip)
|
47
|
+
end
|
48
|
+
count += 1
|
190
49
|
end
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
50
|
+
assert_equal(2, count -1)
|
51
|
+
assert_equal(2, $ie.table(:index, 2)[2].column_count)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_dynamic_tables
|
55
|
+
t = $ie.table(:id, 't1')
|
56
|
+
assert_equal(5, t.row_count)
|
57
|
+
|
58
|
+
$ie.button(:value, 'add row').click
|
59
|
+
assert_equal(6, t.row_count)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_columns
|
63
|
+
assert_raises(UnknownObjectException ){ $ie.table(:id, 'missingTable').column_count }
|
64
|
+
assert_raises(UnknownObjectException ){ $ie.table(:index, 77).column_count }
|
65
|
+
assert_equal(2, $ie.table(:index, 1).column_count)
|
66
|
+
assert_equal(1, $ie.table(:id, 't1').column_count) # row one has 1 cell with a colspan of 2
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_to_a
|
70
|
+
table1Expected = [ ["Row 1 Col1" , "Row 1 Col2"] ,[ "Row 2 Col1" , "Row 2 Col2"] ]
|
71
|
+
assert_equal(table1Expected, $ie.table(:index , 1).to_a )
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_links_and_images_in_table
|
75
|
+
table = $ie.table(:id, 'pic_table')
|
76
|
+
image = table[1][2].image(:index,1)
|
77
|
+
assert_equal("106", image.width)
|
78
|
+
|
79
|
+
link = table[1][4].link(:index,1)
|
80
|
+
assert_equal("Google", link.innerText)
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_cell_directly
|
84
|
+
assert( $ie.cell(:id, 'cell1').exists? )
|
85
|
+
assert(! $ie.cell(:id, 'no_exist').exists? )
|
86
|
+
assert_equal( "Row 1 Col1", $ie.cell(:id, 'cell1').to_s.strip )
|
87
|
+
|
88
|
+
# not really cell directly, but just to show another way of geting the cell
|
89
|
+
assert_equal( "Row 1 Col1", $ie.table(:index,1)[1][1].to_s.strip )
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_row_directly
|
93
|
+
assert( $ie.row(:id, 'row1').exists? )
|
94
|
+
assert(! $ie.row(:id, 'no_exist').exists? )
|
95
|
+
|
96
|
+
assert_equal('Row 2 Col1' , $ie.row(:id, 'row1')[1].to_s.strip )
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_row_iterator
|
100
|
+
t = $ie.table(:index, 1)
|
101
|
+
count = 1
|
102
|
+
t.each do |row|
|
103
|
+
if count == 1
|
104
|
+
assert("Row 1 Col1", row[1].text)
|
105
|
+
assert("Row 1 Col2", row[2].text)
|
106
|
+
elsif count == 2
|
107
|
+
assert("Row 2 Col1", row[1].text)
|
108
|
+
assert("Row 2 Col2", row[2].text)
|
109
|
+
end
|
110
|
+
count += 1
|
200
111
|
end
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_row_collection
|
115
|
+
t = $ie.table(:index,1)
|
116
|
+
count = 1
|
117
|
+
t.rows.each do |row|
|
118
|
+
if count == 1
|
119
|
+
assert("Row 1 Col1", row[1].text)
|
120
|
+
assert("Row 1 Col2", row[2].text)
|
121
|
+
elsif count == 2
|
122
|
+
assert("Row 2 Col1", row[1].text)
|
123
|
+
assert("Row 2 Col2", row[2].text)
|
124
|
+
end
|
125
|
+
count += 1
|
207
126
|
end
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_cell_collection
|
130
|
+
t = $ie.table(:index,1)
|
131
|
+
count = 1
|
132
|
+
contents = t.cells.collect {|c| c.text}
|
133
|
+
assert_equal(["Row 1 Col1","Row 1 Col2","Row 2 Col1","Row 2 Col2"], contents)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_table_body
|
137
|
+
assert_equal( 1, $ie.table(:index,1).bodies.length )
|
138
|
+
assert_equal( 3, $ie.table(:id, 'body_test' ).bodies.length )
|
139
|
+
|
140
|
+
count = 1
|
141
|
+
$ie.table(:id, 'body_test').bodies.each do |n|
|
142
|
+
|
143
|
+
# do something better here!
|
144
|
+
# n.flash # this line commented out to speed up the test
|
145
|
+
|
146
|
+
case count
|
147
|
+
when 1
|
148
|
+
compare_text = "This text is in the FRST TBODY."
|
149
|
+
when 2
|
150
|
+
compare_text = "This text is in the SECOND TBODY."
|
151
|
+
when 3
|
152
|
+
compare_text = "This text is in the THIRD TBODY."
|
153
|
+
end
|
154
|
+
|
155
|
+
assert_equal(compare_text, n[1][1].to_s.strip ) # this is the 1st cell of the first row of this particular body
|
156
|
+
|
157
|
+
count += 1
|
221
158
|
end
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
when 2
|
237
|
-
compare_text = "This text is in the SECOND TBODY."
|
238
|
-
when 3
|
239
|
-
compare_text = "This text is in the THIRD TBODY."
|
240
|
-
end
|
241
|
-
|
242
|
-
assert_equal( compare_text , n[1][1].to_s.strip ) # this is the 1st cell of the first row of this particular body
|
243
|
-
|
244
|
-
count +=1
|
245
|
-
end
|
246
|
-
assert_equal( count-1, $ie.table(:id, 'body_test' ).bodies.length )
|
247
|
-
|
248
|
-
assert_equal( "This text is in the THIRD TBODY." ,$ie.table(:id, 'body_test' ).body(:index,3)[1][1].to_s.strip )
|
249
|
-
|
250
|
-
# iterate through all the rows in a table body
|
251
|
-
count = 1
|
252
|
-
$ie.table(:id, 'body_test' ).body(:index,2).each do | row |
|
253
|
-
# row.flash # this line commented out, to speed up the tests
|
254
|
-
if count == 1
|
255
|
-
assert_equal('This text is in the SECOND TBODY.' , row[1].text.strip )
|
256
|
-
elsif count == 1
|
257
|
-
assert_equal('This text is also in the SECOND TBODY.' , row[1].text.strip )
|
258
|
-
end
|
259
|
-
count+=1
|
260
|
-
end
|
159
|
+
assert_equal( count - 1, $ie.table(:id, 'body_test').bodies.length )
|
160
|
+
|
161
|
+
assert_equal( "This text is in the THIRD TBODY." ,$ie.table(:id, 'body_test' ).body(:index,3)[1][1].to_s.strip )
|
162
|
+
|
163
|
+
# iterate through all the rows in a table body
|
164
|
+
count = 1
|
165
|
+
$ie.table(:id, 'body_test').body(:index, 2).each do | row |
|
166
|
+
# row.flash # this line commented out, to speed up the tests
|
167
|
+
if count == 1
|
168
|
+
assert_equal('This text is in the SECOND TBODY.', row[1].text.strip )
|
169
|
+
elsif count == 1 # BUG: Huh?
|
170
|
+
assert_equal('This text is also in the SECOND TBODY.', row[1].text.strip )
|
171
|
+
end
|
172
|
+
count+=1
|
261
173
|
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_table_container
|
177
|
+
assert_nothing_raised { $ie.table(:id, 't1').html }
|
178
|
+
end
|
179
|
+
end
|
262
180
|
|
263
|
-
|
264
|
-
|
265
|
-
|
181
|
+
class TC_Tables_Simple < Test::Unit::TestCase
|
182
|
+
include Watir
|
183
|
+
|
184
|
+
def setup
|
185
|
+
$ie.goto($htmlRoot + "simple_table.html")
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_simple_table_access
|
189
|
+
table = $ie.table(:index,1)
|
190
|
+
|
191
|
+
assert_equal("Row 3 Col1",table[3][1].text.strip)
|
192
|
+
assert_equal("Row 1 Col1",table[1][1].text.strip)
|
193
|
+
assert_equal("Row 3 Col2",table[3][2].text.strip)
|
194
|
+
assert_equal(2,table.column_count)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
class TC_Tables_Buttons < Test::Unit::TestCase
|
198
|
+
include Watir
|
199
|
+
|
200
|
+
def setup
|
201
|
+
$ie.goto($htmlRoot + "simple_table_buttons.html")
|
202
|
+
end
|
203
|
+
|
204
|
+
def test_simple_table_buttons
|
205
|
+
table = $ie.table(:index,1)
|
206
|
+
|
207
|
+
table[1][1].button(:index,1).click
|
208
|
+
assert($ie.textField(:name,"confirmtext").verify_contains(/CLICK1/i))
|
209
|
+
table[2][1].button(:index,1).click
|
210
|
+
assert($ie.textField(:name,"confirmtext").verify_contains(/CLICK2/i))
|
211
|
+
|
212
|
+
table[1][1].button(:id,'b1').click
|
213
|
+
assert($ie.textField(:name,"confirmtext").verify_contains(/CLICK1/i))
|
214
|
+
|
215
|
+
assert_raises(UnknownObjectException ) { table[1][1].button(:id,'b_missing').click }
|
216
|
+
|
217
|
+
table[3][1].button(:index,2).click
|
218
|
+
assert($ie.textField(:name,"confirmtext").verify_contains(/TOO/i))
|
219
|
+
|
220
|
+
table[3][1].button(:value ,"Click too").click
|
221
|
+
assert($ie.textField(:name,"confirmtext").verify_contains(/TOO/i))
|
222
|
+
|
223
|
+
$ie.table(:index,1)[4][1].text_field(:index,1).set("123")
|
224
|
+
assert($ie.text_field(:index,2).verify_contains("123"))
|
225
|
+
|
226
|
+
# check when a cell contains 2 objects
|
227
|
+
|
228
|
+
# if there were 2 different html objects in the same cell, some weird things happened ( button caption could change for example)
|
229
|
+
assert_equal( 'Click ->' , $ie.table(:index,1)[5][1].text_field(:index,1).value )
|
230
|
+
$ie.table(:index,1)[5][1].text_field(:index,1).click
|
231
|
+
assert_equal( 'Click ->' , $ie.table(:index,1)[5][1].text_field(:index,1).value )
|
232
|
+
|
233
|
+
$ie.table(:index,1)[5][1].button(:index,1).click
|
234
|
+
assert_equal( '' , $ie.table(:index,1)[5][1].text_field(:index,1).value )
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_simple_table_gif
|
238
|
+
table = $ie.table(:index,2)
|
239
|
+
|
240
|
+
assert_match( /1\.gif/ , table[1][1].image( :index,1).src )
|
241
|
+
assert_match( /2\.gif/ , table[1][2].image( :index ,1).src )
|
242
|
+
assert_match( /3\.gif/ , table[1][3].image( :index ,1).src )
|
243
|
+
|
244
|
+
assert_match( /1\.gif/ , table[3][1].image( :index ,1).src )
|
245
|
+
assert_match( /2\.gif/ , table[3][2].image( :index ,1).src )
|
246
|
+
assert_match( /3\.gif/ , table[3][3].image( :index ,1).src )
|
247
|
+
|
248
|
+
table = $ie.table(:index,3)
|
249
|
+
assert_match( /1\.gif/ , table[1][1].image( :index ,1).src )
|
250
|
+
assert_match( /2\.gif/ , table[1][1].image( :index ,2).src )
|
251
|
+
assert_match( /3\.gif/ , table[1][1].image( :index ,3).src )
|
252
|
+
|
253
|
+
assert_match( /1\.gif/ , table[3][1].image( :index ,1).src )
|
254
|
+
assert_match( /2\.gif/ , table[3][1].image( :index ,2).src )
|
255
|
+
assert_match( /3\.gif/ , table[3][1].image( :index ,3).src )
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_table_with_hidden_or_visible_rows
|
259
|
+
t = $ie.table(:id , 'show_hide')
|
260
|
+
|
261
|
+
# expand the table
|
262
|
+
t.each do |r|
|
263
|
+
r[1].image(:src, /plus/).click if r[1].image(:src, /plus/).exists?
|
266
264
|
end
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
265
|
+
|
266
|
+
# shrink rows 1,2,3
|
267
|
+
count=1
|
268
|
+
t.each do |r|
|
269
|
+
r[1].image(:src, /minus/).click if r[1].image(:src, /minus/).exists? and (1..3) === count
|
270
|
+
count=2
|
274
271
|
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_table_from_element
|
275
|
+
button = $ie.button(:id, "b1")
|
276
|
+
table = Table.create_from_element($ie, button)
|
277
|
+
|
278
|
+
table[2][1].button(:index, 1).click
|
279
|
+
assert($ie.textField(:name, "confirmtext").verify_contains(/CLICK2/i))
|
280
|
+
end
|
281
|
+
end
|
275
282
|
|
283
|
+
class TC_Table_Columns < Test::Unit::TestCase
|
284
|
+
include Watir
|
285
|
+
def setup
|
286
|
+
$ie.goto($htmlRoot + "simple_table_columns.html")
|
287
|
+
end
|
288
|
+
|
289
|
+
def test_get_columnvalues_single_column
|
290
|
+
assert_equal(["R1C1", "R2C1", "R3C1"], $ie.table(:index, 1).column_values(1))
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_colspan
|
294
|
+
assert_equal(2, $ie.table(:index, 3)[2][1].colspan)
|
295
|
+
assert_equal(1, $ie.table(:index, 3)[1][1].colspan)
|
296
|
+
assert_equal(3, $ie.table(:index, 3)[4][1].colspan)
|
297
|
+
end
|
298
|
+
|
299
|
+
def test_get_columnvalues_multiple_column
|
300
|
+
assert_equal(["R1C1", "R2C1", "R3C1"], $ie.table(:index, 2).column_values(1))
|
301
|
+
assert_equal(["R1C3", "R2C3", "R3C3"], $ie.table(:index, 2).column_values(3))
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_get_columnvalues_with_colspan
|
305
|
+
assert_equal(["R1C1", "R2C1", "R3C1", "R4C1", "R5C1", "R6C2"], $ie.table(:index, 3).column_values(1))
|
306
|
+
(2..4).each{|x|assert_raises(UnknownCellException){$ie.table(:index, 3).column_values(x)}}
|
307
|
+
end
|
308
|
+
|
309
|
+
def test_get_rowvalues_full_row
|
310
|
+
assert_equal(["R1C1", "R1C2", "R1C3"], $ie.table(:index, 3).row_values(1))
|
311
|
+
end
|
312
|
+
|
313
|
+
def test_get_rowvalues_with_colspan
|
314
|
+
assert_equal(["R2C1", "R2C2"], $ie.table(:index, 3).row_values(2))
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_getrowvalues_with_rowspan
|
318
|
+
assert_equal(["R5C1", "R5C2", "R5C3"], $ie.table(:index, 3).row_values(5))
|
319
|
+
assert_equal(["R6C2", "R6C3"], $ie.table(:index, 3).row_values(6))
|
320
|
+
end
|
321
|
+
end
|
276
322
|
|
323
|
+
class TC_Tables_Complex < Test::Unit::TestCase
|
324
|
+
include Watir
|
325
|
+
def setup
|
326
|
+
$ie.goto($htmlRoot + "complex_table.html")
|
327
|
+
end
|
277
328
|
|
278
|
-
|
279
|
-
|
280
|
-
$ie.goto($htmlRoot + "simple_table_columns.html")
|
281
|
-
assert_equal(["R1C1", "R2C1", "R3C1"], $ie.table(:index, 2).column_values(1))
|
282
|
-
assert_equal(["R1C3", "R2C3", "R3C3"], $ie.table(:index, 2).column_values(3))
|
283
|
-
end
|
284
|
-
|
285
|
-
def test_get_columnvalues_with_colspan
|
286
|
-
$ie.goto($htmlRoot + "simple_table_columns.html")
|
287
|
-
assert_equal(["R1C1", "R2C1", "R3C1", "R4C1", "R5C1", "R6C2"], $ie.table(:index, 3).column_values(1))
|
288
|
-
(2..4).each{|x|assert_raises(UnknownCellException){$ie.table(:index, 3).column_values(x)}}
|
289
|
-
end
|
290
|
-
|
291
|
-
def test_get_rowvalues_full_row
|
292
|
-
$ie.goto($htmlRoot + "simple_table_columns.html")
|
293
|
-
assert_equal(["R1C1", "R1C2", "R1C3"], $ie.table(:index, 3).row_values(1))
|
294
|
-
end
|
329
|
+
def test_complex_table_access
|
330
|
+
table = $ie.table(:index,1)
|
295
331
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
def test_getrowvalues_with_rowspan
|
302
|
-
$ie.goto($htmlRoot + "simple_table_columns.html")
|
303
|
-
assert_equal(["R5C1", "R5C2", "R5C3"], $ie.table(:index, 3).row_values(5))
|
304
|
-
assert_equal(["R6C2", "R6C3"], $ie.table(:index, 3).row_values(6))
|
305
|
-
end
|
332
|
+
assert_equal("subtable1 Row 1 Col1",table[1][1].table(:index,1)[1][1].text.strip)
|
333
|
+
assert_equal("subtable1 Row 1 Col2",table[1][1].table(:index,1)[1][2].text.strip)
|
334
|
+
assert_equal("subtable2 Row 1 Col2",table[2][1].table(:index,1)[1][2].text.strip)
|
335
|
+
assert_equal("subtable2 Row 1 Col1",table[2][1].table(:index,1)[1][1].text.strip)
|
336
|
+
end
|
306
337
|
end
|