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.
Files changed (151) hide show
  1. data/bin/watir-console +1 -0
  2. data/changes.rb +119 -0
  3. data/license.rb +37 -0
  4. data/readme.rb +55 -120
  5. data/unittests/buttons_test.rb +107 -104
  6. data/unittests/buttons_xpath_test.rb +69 -0
  7. data/unittests/checkbox_test.rb +154 -141
  8. data/unittests/checkbox_xpath_test.rb +107 -0
  9. data/unittests/core_tests.rb +6 -2
  10. data/unittests/css_test.rb +50 -50
  11. data/unittests/defer_test.rb +47 -0
  12. data/unittests/dialog_test.rb +78 -0
  13. data/unittests/div2_xpath_test.rb +22 -0
  14. data/unittests/div_test.rb +159 -159
  15. data/unittests/div_xpath_test.rb +96 -0
  16. data/unittests/errorchecker_test.rb +22 -22
  17. data/unittests/filefield_test.rb +30 -23
  18. data/unittests/filefield_xpath_test.rb +35 -0
  19. data/unittests/form_test.rb +250 -229
  20. data/unittests/form_xpath_test.rb +253 -0
  21. data/unittests/frame_test.rb +123 -108
  22. data/unittests/google_form_test.rb +17 -0
  23. data/unittests/html/JavascriptClick.html +39 -0
  24. data/unittests/html/buttons1.html +3 -2
  25. data/unittests/html/checkboxes1.html +32 -14
  26. data/unittests/html/complex_table.html +1 -1
  27. data/unittests/html/depot_store.html +59 -0
  28. data/unittests/html/div.html +3 -21
  29. data/unittests/html/div_xml.html +21 -0
  30. data/unittests/html/fileupload.html +2 -2
  31. data/unittests/html/forms2.html +3 -3
  32. data/unittests/html/forms3.html +2 -2
  33. data/unittests/html/frame_links.html +2 -2
  34. data/unittests/html/google_india.html +119 -0
  35. data/unittests/html/iframeTest.html +2 -2
  36. data/unittests/html/images/map.GIF +0 -0
  37. data/unittests/html/images/map2.gif +0 -0
  38. data/unittests/html/images1.html +17 -2
  39. data/unittests/html/javascriptevents.html +3 -7
  40. data/unittests/html/links1.html +9 -8
  41. data/unittests/html/links_multi.html +14 -0
  42. data/unittests/html/list_matters.html +720 -0
  43. data/unittests/html/lists.html +18 -0
  44. data/unittests/html/map_test.html +31 -0
  45. data/unittests/html/modal_dialog.html +10 -0
  46. data/unittests/html/modal_dialog_launcher.html +12 -0
  47. data/unittests/html/new_browser.html +17 -0
  48. data/unittests/html/pass.html +3 -0
  49. data/unittests/html/popups1.html +1 -1
  50. data/unittests/html/pre.html +28 -0
  51. data/unittests/html/radioButtons1.html +6 -5
  52. data/unittests/html/selectboxes1.html +12 -11
  53. data/unittests/html/simple_table.html +1 -1
  54. data/unittests/html/simple_table_columns.html +1 -1
  55. data/unittests/html/table1.html +1 -1
  56. data/unittests/html/tableCell_using_xpath.html +19 -0
  57. data/unittests/html/textfields1.html +6 -4
  58. data/unittests/html/xpath_nbsp.html +12 -0
  59. data/unittests/ie_exists_test.rb +32 -0
  60. data/unittests/ie_mock.rb +78 -79
  61. data/unittests/ie_test.rb +39 -39
  62. data/unittests/images_test.rb +132 -155
  63. data/unittests/images_xpath_test.rb +91 -0
  64. data/unittests/links_multi_test.rb +36 -0
  65. data/unittests/links_test.rb +158 -152
  66. data/unittests/links_xpath_test.rb +40 -0
  67. data/unittests/lists_test.rb +29 -0
  68. data/unittests/map_test.rb +99 -0
  69. data/unittests/minmax_test.rb +23 -23
  70. data/unittests/navigate_test.rb +43 -51
  71. data/unittests/nbsp_xpath_test.rb +18 -0
  72. data/unittests/other/WindowLogonExample.rb +28 -0
  73. data/unittests/{WindowLogonExtra.rb → other/WindowLogonExtra.rb} +0 -0
  74. data/unittests/{all_tests_concurrent.rb → other/all_tests_concurrent.rb} +23 -23
  75. data/unittests/other/navigate_exception_test.rb +14 -0
  76. data/unittests/other/rexml_unit_test.rb +24 -0
  77. data/unittests/other/testcase_method_order_test.rb +36 -0
  78. data/unittests/other/testcase_verify_test.rb +25 -0
  79. data/unittests/other/wait_until_test.rb +99 -0
  80. data/unittests/pagecontainstext_test.rb +56 -37
  81. data/unittests/parent_child_test.rb +55 -0
  82. data/unittests/popups_test.rb +37 -37
  83. data/unittests/pre_test.rb +52 -0
  84. data/unittests/radios_test.rb +186 -155
  85. data/unittests/radios_xpath_test.rb +101 -0
  86. data/unittests/screen_capture_test.rb +41 -41
  87. data/unittests/selectbox_test.rb +223 -181
  88. data/unittests/selectbox_xpath_test.rb +113 -0
  89. data/unittests/setup.rb +29 -25
  90. data/unittests/speed_settings_test.rb +22 -0
  91. data/unittests/table_cell_using_xpath_test.rb +40 -0
  92. data/unittests/table_test.rb +315 -284
  93. data/unittests/table_xpath_test.rb +114 -0
  94. data/unittests/textarea_test.rb +81 -0
  95. data/unittests/textarea_xpath_test.rb +82 -0
  96. data/unittests/textfields_test.rb +205 -229
  97. data/unittests/textfields_xpath_test.rb +111 -0
  98. data/unittests/window_tests.rb +7 -0
  99. data/unittests/windows/attach_to_existing_window_test.rb +52 -0
  100. data/unittests/windows/attach_to_new_window_test.rb +82 -0
  101. data/unittests/windows/close_window_test.rb +22 -0
  102. data/unittests/windows/frame_links_test.rb +25 -0
  103. data/unittests/windows/ie-each_test.rb +48 -0
  104. data/unittests/windows/iedialog_test.rb +55 -0
  105. data/unittests/windows/js_events_test.rb +57 -0
  106. data/unittests/windows/jscriptExtraAlert.rb +6 -0
  107. data/unittests/windows/jscriptExtraConfirmCancel.rb +7 -0
  108. data/unittests/windows/jscriptExtraConfirmOk.rb +7 -0
  109. data/unittests/{jscriptPushButton.rb → windows/jscriptPushButton.rb} +1 -1
  110. data/unittests/windows/jscript_test.rb +64 -0
  111. data/unittests/windows/modal_dialog_test.rb +127 -0
  112. data/unittests/windows/new.rb +56 -0
  113. data/unittests/windows/open_close_test.rb +22 -0
  114. data/unittests/windows/send_keys_test.rb +34 -0
  115. data/unittests/xpath_tests.rb +10 -0
  116. data/watir.rb +4344 -3565
  117. data/watir/IEDialog/Release/IEDialog.dll +0 -0
  118. data/watir/WindowHelper.rb +13 -11
  119. data/watir/assertions.rb +36 -0
  120. data/watir/camel_case.rb +14 -5
  121. data/watir/close_all.rb +38 -0
  122. data/watir/contrib/enabled_popup.rb +21 -0
  123. data/watir/contrib/ie-new-process.rb +27 -0
  124. data/watir/contrib/page_checker.rb +29 -0
  125. data/watir/contrib/visible.rb +47 -0
  126. data/watir/cookiemanager.rb +4 -4
  127. data/watir/datahandler.rb +107 -0
  128. data/watir/dialog.rb +46 -0
  129. data/watir/elements.rb +65 -0
  130. data/watir/exceptions.rb +18 -36
  131. data/watir/ie-process.rb +40 -0
  132. data/watir/irb-history.rb +31 -0
  133. data/watir/process.rb +20 -0
  134. data/watir/testUnitAddons.rb +3 -42
  135. data/watir/testcase.rb +58 -0
  136. data/watir/utils.rb +20 -0
  137. data/watir/waiter.rb +88 -0
  138. data/watir/watir_simple.rb +4 -4
  139. data/watir/win32ole.rb +8 -0
  140. data/watir/win32ole/win32ole.so +0 -0
  141. data/watir/winClicker.rb +374 -400
  142. metadata +209 -128
  143. data/unittests/WindowLogonExample.rb +0 -30
  144. data/unittests/attachToExistingWindow_test.rb +0 -40
  145. data/unittests/js_events_test.rb +0 -77
  146. data/unittests/jscriptExtraAlert.rb +0 -6
  147. data/unittests/jscriptExtraConfirmCancel.rb +0 -7
  148. data/unittests/jscriptExtraConfirmOk.rb +0 -7
  149. data/unittests/jscript_test.rb +0 -57
  150. data/unittests/send_keys_test.rb +0 -29
  151. 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
@@ -1,169 +1,175 @@
1
1
  # feature tests for Links
2
- # revision: $Revision: 1.33 $
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
- include Watir
9
-
10
- def gotoLinksPage()
11
- $ie.goto($htmlRoot + "links1.html")
12
- end
13
-
14
- def gotoFrameLinksPage()
15
- $ie.goto($htmlRoot + "frame_links.html")
16
- end
17
-
18
- def setup()
19
- gotoLinksPage()
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
- def test_links_in_frames
36
- gotoFrameLinksPage()
37
-
38
- assert($ie.frame("buttonFrame").link(:text, "test1").exists?)
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
- def test_Link_Exists
53
- assert($ie.link(:text, "test1").exists?)
54
- assert($ie.link(:text, /TEST/i).exists?)
55
- assert_false($ie.link(:text, "missing").exists?)
56
- assert_false($ie.link(:text, /miss/).exists?)
57
-
58
- # this assert we have to build up the path
59
- # this is what it looks like if you do a to_s on the link file:///C:/watir_bonus/unitTests/html/links1.HTML
60
- # but what we get back from $htmlRoot is a mixed case, so its almost impossible for use to test this correctly
61
- # assert($ie.link(:url,'file:///C:/watir_bonus/unitTests/html/links1.HTML' ).exists?)
62
-
63
- assert($ie.link(:url, /link_pass.html/).exists?)
64
- assert_false($ie.link(:url, "alsomissing.html").exists?)
65
-
66
- assert($ie.link(:id, "link_id").exists?)
67
- assert_false($ie.link(:id, "alsomissing").exists?)
68
-
69
- assert($ie.link(:id, /_id/).exists?)
70
- assert_false($ie.link(:id, /alsomissing/).exists?)
71
-
72
- assert($ie.link(:name, "link_name").exists?)
73
- assert_false($ie.link(:name, "alsomissing").exists?)
74
-
75
- assert($ie.link(:name, /_n/).exists?)
76
- assert_false($ie.link(:name, /missing/).exists?)
77
-
78
- assert($ie.link(:title, /ti/).exists?)
79
- assert($ie.link(:title, "link_title").exists?)
80
-
81
- assert_false($ie.link(:title, /missing/).exists?)
82
-
83
- assert($ie.link(:url, /_pass/).exists?)
84
- assert_false($ie.link(:url, /dont_exist/).exists?)
85
- end
86
-
87
- def test_Link_click
88
- $ie.link(:text, "test1").click
89
- assert( $ie.contains_text("Links2-Pass") )
90
-
91
- gotoLinksPage()
92
- $ie.link(:url, /link_pass.html/).click
93
- assert( $ie.contains_text("Links3-Pass") )
94
-
95
- gotoLinksPage()
96
-
97
- $ie.link(:index, 1).click
98
- assert( $ie.contains_text("Links2-Pass") )
99
-
100
- gotoLinksPage()
101
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).click }
102
- end
103
-
104
- def test_link_properties
105
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).href }
106
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).value}
107
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).innerText }
108
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).name }
109
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).id }
110
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).disabled }
111
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.link(:index, 199).type }
112
-
113
- assert_match( /links2/ ,$ie.link(:index, 1).href )
114
- assert_equal( "" , $ie.link(:index, 1).value)
115
- assert_equal( "test1" , $ie.link(:index, 1).innerText )
116
- assert_equal( "" , $ie.link(:index, 1).name )
117
- assert_equal( "" , $ie.link(:index, 1).id )
118
- assert_equal( false , $ie.link(:index, 1).disabled )
119
- assert_equal( "link" , $ie.link(:index, 1).type )
120
-
121
- assert_equal( "link_id" , $ie.link(:index, 6).id )
122
- assert_equal( "link_name" , $ie.link(:index, 7).name )
123
-
124
- assert_equal( "" , $ie.link(:index, 7).title)
125
-
126
- assert_equal( "link_title" , $ie.link(:index, 8).title)
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
- def test_link_iterator
130
- assert_equal(9, $ie.links.length )
131
- assert_equal("Link Using a name" , $ie.links[7].innerText)
132
-
133
- index = 1
134
- $ie.links.each do |link|
135
- assert_equal( $ie.link(:index, index).href , link.href )
136
- assert_equal( $ie.link(:index, index).id , link.id )
137
- assert_equal( $ie.link(:index, index).name , link.name )
138
- assert_equal( $ie.link(:index, index).innerText , link.innerText )
139
- index+=1
140
- end
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
- include MockStdoutTestCase
147
-
148
- def test_showLinks
149
- $ie.goto($htmlRoot + "links1.html")
150
- $stdout = @mockout
151
- $ie.showLinks
152
- expected = [/^index name +id +href + text\/src$/,
153
- get_path_regex(1, "links2.html","test1"),
154
- get_path_regex(2, "link_pass.html","test1"),
155
- get_path_regex(3, "pass3.html", " / file:///#{$myDir.downcase}/html/images/button.jpg"),
156
- get_path_regex(4, "textarea.html", "new window"),
157
- get_path_regex(5, "textarea.html", "new window"),
158
- get_path_regex(6, "links1.html", "link using an id", "link_id"),
159
- get_path_regex(7, "links1.html", "link using a name", "link_name"),
160
- get_path_regex(8, "links1.html", "link using a title"),
161
- get_path_regex(9, "pass.html", "image and a text link / file:///#{$myDir.downcase}/html/images/triangle.jpg")]
162
- items = @mockout.split(/\n/).collect {|s|s.downcase.strip}
163
- expected.each_with_index{|regex, x| assert_match(regex, items[x])}
164
- end
165
-
166
- def get_path_regex(idx, name, inner, nameid="")
167
- Regexp.new("^#{idx} +#{nameid} +file:///#{$myDir.downcase}/html/#{name} *#{inner}$")
168
- end
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
+