watir 1.4.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/watir-console +1 -0
- data/changes.rb +119 -0
- data/license.rb +37 -0
- data/readme.rb +55 -120
- data/unittests/buttons_test.rb +107 -104
- data/unittests/buttons_xpath_test.rb +69 -0
- data/unittests/checkbox_test.rb +154 -141
- data/unittests/checkbox_xpath_test.rb +107 -0
- data/unittests/core_tests.rb +6 -2
- data/unittests/css_test.rb +50 -50
- data/unittests/defer_test.rb +47 -0
- data/unittests/dialog_test.rb +78 -0
- data/unittests/div2_xpath_test.rb +22 -0
- data/unittests/div_test.rb +159 -159
- data/unittests/div_xpath_test.rb +96 -0
- data/unittests/errorchecker_test.rb +22 -22
- data/unittests/filefield_test.rb +30 -23
- data/unittests/filefield_xpath_test.rb +35 -0
- data/unittests/form_test.rb +250 -229
- data/unittests/form_xpath_test.rb +253 -0
- data/unittests/frame_test.rb +123 -108
- data/unittests/google_form_test.rb +17 -0
- data/unittests/html/JavascriptClick.html +39 -0
- data/unittests/html/buttons1.html +3 -2
- data/unittests/html/checkboxes1.html +32 -14
- data/unittests/html/complex_table.html +1 -1
- data/unittests/html/depot_store.html +59 -0
- data/unittests/html/div.html +3 -21
- data/unittests/html/div_xml.html +21 -0
- data/unittests/html/fileupload.html +2 -2
- data/unittests/html/forms2.html +3 -3
- data/unittests/html/forms3.html +2 -2
- data/unittests/html/frame_links.html +2 -2
- data/unittests/html/google_india.html +119 -0
- data/unittests/html/iframeTest.html +2 -2
- data/unittests/html/images/map.GIF +0 -0
- data/unittests/html/images/map2.gif +0 -0
- data/unittests/html/images1.html +17 -2
- data/unittests/html/javascriptevents.html +3 -7
- data/unittests/html/links1.html +9 -8
- data/unittests/html/links_multi.html +14 -0
- data/unittests/html/list_matters.html +720 -0
- data/unittests/html/lists.html +18 -0
- data/unittests/html/map_test.html +31 -0
- data/unittests/html/modal_dialog.html +10 -0
- data/unittests/html/modal_dialog_launcher.html +12 -0
- data/unittests/html/new_browser.html +17 -0
- data/unittests/html/pass.html +3 -0
- data/unittests/html/popups1.html +1 -1
- data/unittests/html/pre.html +28 -0
- data/unittests/html/radioButtons1.html +6 -5
- data/unittests/html/selectboxes1.html +12 -11
- data/unittests/html/simple_table.html +1 -1
- data/unittests/html/simple_table_columns.html +1 -1
- data/unittests/html/table1.html +1 -1
- data/unittests/html/tableCell_using_xpath.html +19 -0
- data/unittests/html/textfields1.html +6 -4
- data/unittests/html/xpath_nbsp.html +12 -0
- data/unittests/ie_exists_test.rb +32 -0
- data/unittests/ie_mock.rb +78 -79
- data/unittests/ie_test.rb +39 -39
- data/unittests/images_test.rb +132 -155
- data/unittests/images_xpath_test.rb +91 -0
- data/unittests/links_multi_test.rb +36 -0
- data/unittests/links_test.rb +158 -152
- data/unittests/links_xpath_test.rb +40 -0
- data/unittests/lists_test.rb +29 -0
- data/unittests/map_test.rb +99 -0
- data/unittests/minmax_test.rb +23 -23
- data/unittests/navigate_test.rb +43 -51
- data/unittests/nbsp_xpath_test.rb +18 -0
- data/unittests/other/WindowLogonExample.rb +28 -0
- data/unittests/{WindowLogonExtra.rb → other/WindowLogonExtra.rb} +0 -0
- data/unittests/{all_tests_concurrent.rb → other/all_tests_concurrent.rb} +23 -23
- data/unittests/other/navigate_exception_test.rb +14 -0
- data/unittests/other/rexml_unit_test.rb +24 -0
- data/unittests/other/testcase_method_order_test.rb +36 -0
- data/unittests/other/testcase_verify_test.rb +25 -0
- data/unittests/other/wait_until_test.rb +99 -0
- data/unittests/pagecontainstext_test.rb +56 -37
- data/unittests/parent_child_test.rb +55 -0
- data/unittests/popups_test.rb +37 -37
- data/unittests/pre_test.rb +52 -0
- data/unittests/radios_test.rb +186 -155
- data/unittests/radios_xpath_test.rb +101 -0
- data/unittests/screen_capture_test.rb +41 -41
- data/unittests/selectbox_test.rb +223 -181
- data/unittests/selectbox_xpath_test.rb +113 -0
- data/unittests/setup.rb +29 -25
- data/unittests/speed_settings_test.rb +22 -0
- data/unittests/table_cell_using_xpath_test.rb +40 -0
- data/unittests/table_test.rb +315 -284
- data/unittests/table_xpath_test.rb +114 -0
- data/unittests/textarea_test.rb +81 -0
- data/unittests/textarea_xpath_test.rb +82 -0
- data/unittests/textfields_test.rb +205 -229
- data/unittests/textfields_xpath_test.rb +111 -0
- data/unittests/window_tests.rb +7 -0
- data/unittests/windows/attach_to_existing_window_test.rb +52 -0
- data/unittests/windows/attach_to_new_window_test.rb +82 -0
- data/unittests/windows/close_window_test.rb +22 -0
- data/unittests/windows/frame_links_test.rb +25 -0
- data/unittests/windows/ie-each_test.rb +48 -0
- data/unittests/windows/iedialog_test.rb +55 -0
- data/unittests/windows/js_events_test.rb +57 -0
- data/unittests/windows/jscriptExtraAlert.rb +6 -0
- data/unittests/windows/jscriptExtraConfirmCancel.rb +7 -0
- data/unittests/windows/jscriptExtraConfirmOk.rb +7 -0
- data/unittests/{jscriptPushButton.rb → windows/jscriptPushButton.rb} +1 -1
- data/unittests/windows/jscript_test.rb +64 -0
- data/unittests/windows/modal_dialog_test.rb +127 -0
- data/unittests/windows/new.rb +56 -0
- data/unittests/windows/open_close_test.rb +22 -0
- data/unittests/windows/send_keys_test.rb +34 -0
- data/unittests/xpath_tests.rb +10 -0
- data/watir.rb +4344 -3565
- data/watir/IEDialog/Release/IEDialog.dll +0 -0
- data/watir/WindowHelper.rb +13 -11
- data/watir/assertions.rb +36 -0
- data/watir/camel_case.rb +14 -5
- data/watir/close_all.rb +38 -0
- data/watir/contrib/enabled_popup.rb +21 -0
- data/watir/contrib/ie-new-process.rb +27 -0
- data/watir/contrib/page_checker.rb +29 -0
- data/watir/contrib/visible.rb +47 -0
- data/watir/cookiemanager.rb +4 -4
- data/watir/datahandler.rb +107 -0
- data/watir/dialog.rb +46 -0
- data/watir/elements.rb +65 -0
- data/watir/exceptions.rb +18 -36
- data/watir/ie-process.rb +40 -0
- data/watir/irb-history.rb +31 -0
- data/watir/process.rb +20 -0
- data/watir/testUnitAddons.rb +3 -42
- data/watir/testcase.rb +58 -0
- data/watir/utils.rb +20 -0
- data/watir/waiter.rb +88 -0
- data/watir/watir_simple.rb +4 -4
- data/watir/win32ole.rb +8 -0
- data/watir/win32ole/win32ole.so +0 -0
- data/watir/winClicker.rb +374 -400
- metadata +209 -128
- data/unittests/WindowLogonExample.rb +0 -30
- data/unittests/attachToExistingWindow_test.rb +0 -40
- data/unittests/js_events_test.rb +0 -77
- data/unittests/jscriptExtraAlert.rb +0 -6
- data/unittests/jscriptExtraConfirmCancel.rb +0 -7
- data/unittests/jscriptExtraConfirmOk.rb +0 -7
- data/unittests/jscript_test.rb +0 -57
- data/unittests/send_keys_test.rb +0 -29
- data/unittests/textAreafields_test.rb +0 -81
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# feature tests for Links with multiple attributes
|
|
2
|
+
# revision: $Revision: 1009 $
|
|
3
|
+
|
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
|
5
|
+
require 'unittests/setup'
|
|
6
|
+
|
|
7
|
+
class TC_Links_Multi < Test::Unit::TestCase
|
|
8
|
+
include Watir
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
$ie.goto $htmlRoot + 'links_multi.html'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_existing
|
|
15
|
+
assert_match(/not.html/, $ie.link(:class_name, 'Papa').href)
|
|
16
|
+
assert_match(/mama.html/, $ie.link(:text, 'click').href)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_class_alias
|
|
20
|
+
assert_match(/not.html/, $ie.link(:class, 'Papa').href)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_hash_syntax
|
|
24
|
+
assert_match(/not.html/, $ie.link(:class_name => 'Papa').href)
|
|
25
|
+
assert_match(/mama.html/, $ie.link(:text => 'click').href)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_class_and_text
|
|
29
|
+
assert_match(/papa.html/, $ie.link(:class => 'Papa', :text => 'click').href)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_class_and_index
|
|
33
|
+
assert_match(/papa.html/, $ie.link(:class => 'Papa', :index => 2).href)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
data/unittests/links_test.rb
CHANGED
|
@@ -1,169 +1,175 @@
|
|
|
1
1
|
# feature tests for Links
|
|
2
|
-
# revision: $Revision:
|
|
2
|
+
# revision: $Revision: 1078 $
|
|
3
3
|
|
|
4
4
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
|
5
5
|
require 'unittests/setup'
|
|
6
|
+
require 'CGI'
|
|
6
7
|
|
|
7
8
|
class TC_Links < Test::Unit::TestCase
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def xtest_new_link_exists
|
|
23
|
-
assert(exists?{$ie.link(:text, "test1")})
|
|
24
|
-
assert(exists?{$ie.link(:text, /TEST/i)})
|
|
25
|
-
assert_false(exists?{$ie.link(:text, "missing")})
|
|
26
|
-
assert_false(exists?{$ie.link(:text, /miss/)})
|
|
27
|
-
|
|
28
|
-
gotoFrameLinksPage()
|
|
29
|
-
assert(exists?{$ie.frame("buttonFrame").link(:text, "test1")})
|
|
30
|
-
assert_false(exists?{$ie.frame("buttonFrame").link(:text, "missing")})
|
|
31
|
-
|
|
32
|
-
assert_false(exists?{ie.frame("missing").link(:text, "test1")})
|
|
9
|
+
include Watir
|
|
10
|
+
|
|
11
|
+
def setup
|
|
12
|
+
$ie.goto($htmlRoot + "links1.html")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_bad_attribute
|
|
16
|
+
assert_raises(MissingWayOfFindingObjectException) { $ie.link(:bad_attribute, 199).click }
|
|
17
|
+
begin
|
|
18
|
+
$ie.link(:bad_attribute, 199).click
|
|
19
|
+
rescue MissingWayOfFindingObjectException => e
|
|
20
|
+
assert_equal "bad_attribute is an unknown way of finding a <A> element (199)", e.to_s
|
|
33
21
|
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def xtest_missing_links_dont_exist
|
|
25
|
+
assert(!exists?{$ie.link(:text, "missing")})
|
|
26
|
+
assert(!exists?{$ie.link(:text, /miss/)})
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_link_Exists
|
|
30
|
+
assert($ie.link(:text, "test1").exists?)
|
|
31
|
+
assert($ie.link(:text, /TEST/i).exists?)
|
|
32
|
+
assert(!$ie.link(:text, "missing").exists?)
|
|
33
|
+
assert(!$ie.link(:text, /miss/).exists?)
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
assert_false($ie.frame("buttonFrame").link(:text, "missing").exists?)
|
|
40
|
-
|
|
41
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.frame("buttonFrame").link(:index, 199).href }
|
|
42
|
-
assert_match( /links2/ ,$ie.frame("buttonFrame").link(:index, 1).href )
|
|
43
|
-
|
|
44
|
-
count =0
|
|
45
|
-
$ie.frame("buttonFrame").links.each do |l|
|
|
46
|
-
count+=1
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
assert_equal( 9 , count)
|
|
50
|
-
end
|
|
35
|
+
# this assert we have to build up the path
|
|
36
|
+
# this is what it looks like if you do a to_s on the link file:///C:/watir_bonus/unitTests/html/links1.HTML
|
|
37
|
+
# but what we get back from $htmlRoot is a mixed case, so its almost impossible for use to test this correctly
|
|
38
|
+
# assert($ie.link(:url,'file:///C:/watir_bonus/unitTests/html/links1.HTML' ).exists?)
|
|
51
39
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
40
|
+
assert($ie.link(:url, /link_pass.html/).exists?)
|
|
41
|
+
assert(!$ie.link(:url, "alsomissing.html").exists?)
|
|
42
|
+
|
|
43
|
+
assert($ie.link(:id, "link_id").exists?)
|
|
44
|
+
assert(!$ie.link(:id, "alsomissing").exists?)
|
|
45
|
+
|
|
46
|
+
assert($ie.link(:id, /_id/).exists?)
|
|
47
|
+
assert(!$ie.link(:id, /alsomissing/).exists?)
|
|
48
|
+
|
|
49
|
+
assert($ie.link(:name, "link_name").exists?)
|
|
50
|
+
assert(!$ie.link(:name, "alsomissing").exists?)
|
|
51
|
+
|
|
52
|
+
assert($ie.link(:name, /_n/).exists?)
|
|
53
|
+
assert(!$ie.link(:name, /missing/).exists?)
|
|
54
|
+
|
|
55
|
+
assert($ie.link(:title, /ti/).exists?)
|
|
56
|
+
assert($ie.link(:title, "link_title").exists?)
|
|
57
|
+
|
|
58
|
+
assert(!$ie.link(:title, /missing/).exists?)
|
|
59
|
+
|
|
60
|
+
assert($ie.link(:url, /_pass/).exists?)
|
|
61
|
+
assert(!$ie.link(:url, /dont_exist/).exists?)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_link_click
|
|
65
|
+
$ie.link(:text, "test1").click
|
|
66
|
+
assert( $ie.text.include?("Links2-Pass") )
|
|
67
|
+
end
|
|
68
|
+
def test_link2_click
|
|
69
|
+
$ie.link(:url, /link_pass.html/).click
|
|
70
|
+
assert( $ie.text.include?("Links3-Pass") )
|
|
71
|
+
end
|
|
72
|
+
def test_link3_click
|
|
73
|
+
$ie.link(:index, 1).click
|
|
74
|
+
assert( $ie.text.include?("Links2-Pass") )
|
|
75
|
+
end
|
|
76
|
+
def test_link4_click
|
|
77
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).click }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def test_link_properties
|
|
81
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).href }
|
|
82
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).value}
|
|
83
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).innerText }
|
|
84
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).name }
|
|
85
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).id }
|
|
86
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).disabled }
|
|
87
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).type }
|
|
88
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).class_name }
|
|
89
|
+
|
|
90
|
+
assert_match( /links2/ ,$ie.link(:index, 1).href )
|
|
91
|
+
assert_equal( "" , $ie.link(:index, 1).value)
|
|
92
|
+
assert_equal( "test1" , $ie.link(:index, 1).innerText )
|
|
93
|
+
assert_equal( "" , $ie.link(:index, 1).name )
|
|
94
|
+
assert_equal( "" , $ie.link(:index, 1).id )
|
|
95
|
+
assert_equal( false , $ie.link(:index, 1).disabled )
|
|
96
|
+
assert_equal( "" , $ie.link(:index, 1).class_name)
|
|
97
|
+
assert_equal( "link_class_1" , $ie.link(:index, 2).class_name)
|
|
98
|
+
|
|
99
|
+
assert_equal( "link_id" , $ie.link(:index, 6).id )
|
|
100
|
+
assert_equal( "link_name" , $ie.link(:index, 7).name )
|
|
101
|
+
|
|
102
|
+
assert_equal( "" , $ie.link(:index, 7).title)
|
|
103
|
+
|
|
104
|
+
assert_equal( "link_title" , $ie.link(:index, 8).title)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def test_link_iterator
|
|
108
|
+
assert_equal(9, $ie.links.length )
|
|
109
|
+
assert_equal("Link Using a name" , $ie.links[7].innerText)
|
|
110
|
+
|
|
111
|
+
index = 1
|
|
112
|
+
$ie.links.each do |link|
|
|
113
|
+
assert_equal( $ie.link(:index, index).href , link.href )
|
|
114
|
+
assert_equal( $ie.link(:index, index).id , link.id )
|
|
115
|
+
assert_equal( $ie.link(:index, index).name , link.name )
|
|
116
|
+
assert_equal( $ie.link(:index, index).innerText , link.innerText )
|
|
117
|
+
index+=1
|
|
127
118
|
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_div_xml_bug
|
|
122
|
+
$ie.goto($htmlRoot + "div_xml.html")
|
|
123
|
+
assert_nothing_raised {$ie.link(:text, 'Create').exists? }
|
|
124
|
+
end
|
|
125
|
+
end
|
|
128
126
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
127
|
+
class TC_Frame_Links < Test::Unit::TestCase
|
|
128
|
+
include Watir
|
|
129
|
+
|
|
130
|
+
def setup
|
|
131
|
+
$ie.goto($htmlRoot + "frame_links.html")
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def test_links_in_frames
|
|
135
|
+
assert($ie.frame("linkFrame").link(:text, "test1").exists?)
|
|
136
|
+
assert(!$ie.frame("linkFrame").link(:text, "missing").exists?)
|
|
137
|
+
|
|
138
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ie.frame("linkFrame").link(:index, 199).href }
|
|
139
|
+
assert_match(/links2/, $ie.frame("linkFrame").link(:index, 1).href)
|
|
140
|
+
|
|
141
|
+
count =0
|
|
142
|
+
$ie.frame("linkFrame").links.each do |l|
|
|
143
|
+
count+=1
|
|
141
144
|
end
|
|
145
|
+
|
|
146
|
+
assert_equal( 9 , count)
|
|
147
|
+
end
|
|
142
148
|
end
|
|
143
149
|
|
|
144
150
|
require 'unittests/iostring'
|
|
145
151
|
class TC_showlinks < Test::Unit::TestCase
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
152
|
+
include MockStdoutTestCase
|
|
153
|
+
|
|
154
|
+
def test_showLinks
|
|
155
|
+
$ie.goto($htmlRoot + "links1.html")
|
|
156
|
+
$stdout = @mockout
|
|
157
|
+
$ie.showLinks
|
|
158
|
+
expected = [/^index name +id +href + text\/src$/,
|
|
159
|
+
get_path_regex(1, "links2.html", "test1"),
|
|
160
|
+
get_path_regex(2, "link_pass.html", "test1"),
|
|
161
|
+
get_path_regex(3, "pass3.html", " / file:///#{$myDir.downcase}/html/images/button.jpg"),
|
|
162
|
+
get_path_regex(4, "textarea.html", "new window"),
|
|
163
|
+
get_path_regex(5, "textarea.html", "new window"),
|
|
164
|
+
get_path_regex(6, "links1.html", "link using an id", "link_id"),
|
|
165
|
+
get_path_regex(7, "links1.html", "link using a name", "link_name"),
|
|
166
|
+
get_path_regex(8, "links1.html", "link using a title"),
|
|
167
|
+
get_path_regex(9, "pass.html", "image and a text link / file:///#{$myDir.downcase}/html/images/triangle.jpg")]
|
|
168
|
+
items = @mockout.split(/\n/).collect {|s| CGI.unescape(s.downcase.strip)}
|
|
169
|
+
expected.each_with_index{|regex, x| assert_match(regex, items[x])}
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def get_path_regex(idx, name, inner, nameid="")
|
|
173
|
+
Regexp.new("^#{idx} +#{nameid} +file:///#{$myDir.downcase}/html/#{name} *#{inner}$")
|
|
174
|
+
end
|
|
169
175
|
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# feature tests for Links
|
|
2
|
+
# revision: $Revision: 975 $
|
|
3
|
+
|
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
|
5
|
+
require 'unittests/setup'
|
|
6
|
+
|
|
7
|
+
class TC_Links_XPath < Test::Unit::TestCase
|
|
8
|
+
include Watir
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
$ie.goto($htmlRoot + "links1.html")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_link_exists
|
|
15
|
+
assert($ie.link(:xpath, "//a[contains(.,'test1')]/").exists?)
|
|
16
|
+
assert($ie.link(:xpath, "//a[contains(., /TEST/i)]/").exists?)
|
|
17
|
+
assert(!$ie.link(:xpath, "//a[contains(.,'missing')]/").exists?)
|
|
18
|
+
|
|
19
|
+
assert(!$ie.link(:xpath, "//a[@url='alsomissing.html']/").exists?)
|
|
20
|
+
|
|
21
|
+
assert($ie.link(:xpath, "//a[@id='link_id']/").exists?)
|
|
22
|
+
assert(!$ie.link(:xpath, "//a[@id='alsomissing']/").exists?)
|
|
23
|
+
|
|
24
|
+
assert($ie.link(:xpath, "//a[@name='link_name']/").exists?)
|
|
25
|
+
assert(!$ie.link(:xpath, "//a[@name='alsomissing']/").exists?)
|
|
26
|
+
assert($ie.link(:xpath, "//a[@title='link_title']/").exists?)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_link_click
|
|
30
|
+
$ie.link(:xpath, "//a[contains(.,'test1')]/").click
|
|
31
|
+
assert($ie.text.include?("Links2-Pass"))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_link_with_text_call
|
|
35
|
+
$ie.link(:xpath, "//a[text()='test1']").click
|
|
36
|
+
assert($ie.text.include?("Links2-Pass"))
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
|
2
|
+
require 'unittests/setup'
|
|
3
|
+
|
|
4
|
+
class Lists_Tests < Watir::TestCase
|
|
5
|
+
include Watir
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
$ie.goto($htmlRoot + 'lists.html')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_list_items_exist
|
|
12
|
+
assert($ie.li(:id, 'list1').exists?)
|
|
13
|
+
assert($ie.li(:id, 'list2').exists?)
|
|
14
|
+
assert($ie.li(:id, 'list3').exists?)
|
|
15
|
+
assert($ie.li(:id, 'ordered1').exists?)
|
|
16
|
+
assert_equal('Coffee', $ie.li(:index, 1).text)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_list_item_exists_by_name
|
|
20
|
+
assert($ie.li(:name, 'l1').exists?)
|
|
21
|
+
assert ! ($ie.li(:name, 'maptest02').exists?)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_li_length
|
|
25
|
+
assert_equal(6, $ie.lis.length)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
|
2
|
+
require 'unittests/setup'
|
|
3
|
+
|
|
4
|
+
class Map_Tests < Watir::TestCase
|
|
5
|
+
include Watir
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
$ie.goto($htmlRoot + 'map_test.html')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_01
|
|
12
|
+
assert_contains_text "Test Page for Map Tests"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_map_exists_by_name
|
|
16
|
+
assert($ie.map(:name, 'maptest01').exists?)
|
|
17
|
+
assert ! ($ie.map(:name, 'maptest03').exists?)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_map_exists_by_id
|
|
21
|
+
assert($ie.map(:id, 'maptestid01').exists?)
|
|
22
|
+
assert ! ($ie.map(:id, 'maptestid03').exists?)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_map_area_exists_by_href
|
|
26
|
+
assert($ie.area(:url, /pass.html/).exists?)
|
|
27
|
+
assert($ie.area(:url, /simple_table_buttons.html/).exists?)
|
|
28
|
+
assert($ie.area(:url, /images1.html/).exists?)
|
|
29
|
+
assert ! ($ie.area(:url, /blobs.html/).exists?)
|
|
30
|
+
assert($ie.map(:name, 'maptest01').area(:url, /pass.html/).exists?)
|
|
31
|
+
assert($ie.map(:id, 'maptestid01').area(:url, /images1.html/).exists?)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_map_area_exists_by_alt
|
|
35
|
+
assert($ie.area(:alt, 'Pass').exists?)
|
|
36
|
+
assert($ie.area(:alt, 'Table Buttons').exists?)
|
|
37
|
+
assert($ie.area(:alt, 'Images').exists?)
|
|
38
|
+
assert ! ($ie.area(:alt, 'Blobs').exists?)
|
|
39
|
+
assert($ie.map(:name, 'maptest01').area(:alt, 'Pass').exists?)
|
|
40
|
+
assert($ie.map(:id, 'maptestid01').area(:alt, 'Table Buttons').exists?)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_map_area_click
|
|
44
|
+
$ie.area(:alt, 'Table Buttons').click
|
|
45
|
+
assert_contains_text "This table has 3 images"
|
|
46
|
+
$ie.back
|
|
47
|
+
assert_contains_text "Test Page for Map Tests"
|
|
48
|
+
$ie.area(:alt, 'Pass').click
|
|
49
|
+
assert_contains_text "PASS"
|
|
50
|
+
$ie.back
|
|
51
|
+
assert_contains_text "Test Page for Map Tests"
|
|
52
|
+
$ie.area(:alt, 'Images').click
|
|
53
|
+
assert_contains_text "The triangle only has"
|
|
54
|
+
$ie.back
|
|
55
|
+
assert_contains_text "Test Page for Map Tests"
|
|
56
|
+
$ie.area(:url, /simple_table_buttons.html/).click
|
|
57
|
+
assert_contains_text "This table has 3 images"
|
|
58
|
+
$ie.back
|
|
59
|
+
assert_contains_text "Test Page for Map Tests"
|
|
60
|
+
$ie.area(:url, /pass.html/).click
|
|
61
|
+
assert_contains_text "PASS"
|
|
62
|
+
$ie.back
|
|
63
|
+
assert_contains_text "Test Page for Map Tests"
|
|
64
|
+
$ie.area(:url, /images1.html/).click
|
|
65
|
+
assert_contains_text "The triangle only has"
|
|
66
|
+
$ie.back
|
|
67
|
+
assert_contains_text "Test Page for Map Tests"
|
|
68
|
+
$ie.map(:name, 'maptest01').area(:alt, 'Table Buttons').click
|
|
69
|
+
assert_contains_text "This table has 3 images"
|
|
70
|
+
$ie.back
|
|
71
|
+
assert_contains_text "Test Page for Map Tests"
|
|
72
|
+
$ie.map(:id, 'maptestid01').area(:alt, 'Pass').click
|
|
73
|
+
assert_contains_text "PASS"
|
|
74
|
+
$ie.back
|
|
75
|
+
assert_contains_text "Test Page for Map Tests"
|
|
76
|
+
$ie.map(:name, 'maptest01').area(:url, /pass.html/).click
|
|
77
|
+
assert_contains_text "PASS"
|
|
78
|
+
$ie.back
|
|
79
|
+
assert_contains_text "Test Page for Map Tests"
|
|
80
|
+
$ie.map(:id, 'maptestid01').area(:url, /images1.html/).click
|
|
81
|
+
assert_contains_text "The triangle only has"
|
|
82
|
+
$ie.back
|
|
83
|
+
assert_contains_text "Test Page for Map Tests"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def test_maps
|
|
87
|
+
assert_equal(2, $ie.maps.length)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_areas
|
|
91
|
+
assert_equal(3, $ie.map(:index, 2).areas.length)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def assert_contains_text text
|
|
95
|
+
assert($ie.contains_text(text))
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end # class Map_Tests
|
|
99
|
+
|