watir-classic 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. data/.gitignore +7 -0
  2. data/.gitmodules +3 -0
  3. data/.rspec +1 -0
  4. data/.yardopts +5 -0
  5. data/CHANGES +20 -10
  6. data/CONTRIBUTORS.txt +55 -0
  7. data/Gemfile +3 -0
  8. data/Gemfile.lock +78 -0
  9. data/README.rdoc +8 -14
  10. data/Rakefile +32 -0
  11. data/VERSION +1 -1
  12. data/lib/watir-classic.rb +0 -1
  13. data/lib/watir-classic/IEDialog/IEDialog.cpp +225 -0
  14. data/lib/watir-classic/IEDialog/IEDialog.h +15 -0
  15. data/lib/watir-classic/IEDialog/IEDialog.vcproj +159 -0
  16. data/lib/watir-classic/IEDialog/ReadMe.txt +40 -0
  17. data/lib/watir-classic/IEDialog/stdafx.cpp +8 -0
  18. data/lib/watir-classic/IEDialog/stdafx.h +21 -0
  19. data/lib/watir-classic/browser.rb +1 -1
  20. data/lib/watir-classic/container.rb +4 -33
  21. data/lib/watir-classic/core.rb +1 -3
  22. data/lib/watir-classic/dialogs/alert.rb +46 -0
  23. data/lib/watir-classic/dialogs/file_field.rb +1 -0
  24. data/lib/watir-classic/drag_and_drop_helper.rb +18 -6
  25. data/lib/watir-classic/element.rb +0 -2
  26. data/lib/watir-classic/ext/json2.js +487 -0
  27. data/lib/watir-classic/ie-class.rb +10 -164
  28. data/lib/watir-classic/ie.rb +2 -0
  29. data/lib/watir-classic/input_elements.rb +1 -1
  30. data/lib/watir-classic/modal_dialog.rb +1 -7
  31. data/lib/watir-classic/module.rb +1 -10
  32. data/lib/watir-classic/non_control_elements.rb +11 -0
  33. data/lib/watir-classic/page-container.rb +22 -24
  34. data/lib/watir-classic/screenshot.rb +33 -0
  35. data/lib/watir-classic/win32ole/1.8.7/win32ole.patch +56 -0
  36. data/lib/watir-classic/win32ole/1.9.3/win32ole.patch +63 -0
  37. data/lib/watir-classic/win32ole/build_notes.txt +18 -0
  38. data/lib/watir-classic/win32ole/history.txt +88 -0
  39. data/spec/browser_spec.rb +34 -0
  40. data/spec/implementation.rb +18 -0
  41. data/watir-classic.gemspec +40 -0
  42. data/watir.gif +0 -0
  43. metadata +159 -192
  44. data/bin/watir-console +0 -5
  45. data/lib/watir-classic/assertions.rb +0 -44
  46. data/lib/watir-classic/dialogs/javascript.rb +0 -43
  47. data/lib/watir-classic/irb-history.rb +0 -31
  48. data/lib/watir-classic/logger.rb +0 -19
  49. data/lib/watir-classic/screen_capture.rb +0 -115
  50. data/lib/watir-classic/testcase.rb +0 -97
  51. data/lib/watir-classic/waiter.rb +0 -98
  52. data/rakefile.rb +0 -54
  53. data/unittests/all_tests.rb +0 -10
  54. data/unittests/buttons_xpath_test.rb +0 -68
  55. data/unittests/checkbox_test.rb +0 -163
  56. data/unittests/checkbox_xpath_test.rb +0 -106
  57. data/unittests/click_no_wait_test.rb +0 -23
  58. data/unittests/close_all_test.rb +0 -17
  59. data/unittests/core_tests.rb +0 -17
  60. data/unittests/css_selector_test.rb +0 -44
  61. data/unittests/css_test.rb +0 -38
  62. data/unittests/dialog_test.rb +0 -64
  63. data/unittests/div2_xpath_test.rb +0 -21
  64. data/unittests/div_test.rb +0 -170
  65. data/unittests/div_xpath_test.rb +0 -95
  66. data/unittests/document_standards.rb +0 -63
  67. data/unittests/element_collection_indexes_test.rb +0 -57
  68. data/unittests/element_collections_test.rb +0 -100
  69. data/unittests/element_test.rb +0 -47
  70. data/unittests/errorchecker_test.rb +0 -31
  71. data/unittests/filefield_test.rb +0 -43
  72. data/unittests/filefield_xpath_test.rb +0 -35
  73. data/unittests/form_test.rb +0 -282
  74. data/unittests/form_xpath_test.rb +0 -254
  75. data/unittests/frame_test.rb +0 -165
  76. data/unittests/google_form_test.rb +0 -15
  77. data/unittests/html/JavascriptClick.html +0 -39
  78. data/unittests/html/blankpage.html +0 -11
  79. data/unittests/html/buttons1.html +0 -40
  80. data/unittests/html/checkboxes1.html +0 -89
  81. data/unittests/html/click_no_wait.html +0 -14
  82. data/unittests/html/complex_table.html +0 -35
  83. data/unittests/html/cssTest.html +0 -42
  84. data/unittests/html/depot_store.html +0 -59
  85. data/unittests/html/div.html +0 -92
  86. data/unittests/html/div_xml.html +0 -21
  87. data/unittests/html/fileupload.html +0 -44
  88. data/unittests/html/formTest1.html +0 -38
  89. data/unittests/html/forms2.html +0 -44
  90. data/unittests/html/forms3.html +0 -131
  91. data/unittests/html/forms4.html +0 -26
  92. data/unittests/html/frame_buttons.html +0 -4
  93. data/unittests/html/frame_links.html +0 -4
  94. data/unittests/html/frame_multi.html +0 -5
  95. data/unittests/html/google_india.html +0 -119
  96. data/unittests/html/ie7_document_standards.html +0 -9
  97. data/unittests/html/ie8_document_standards.html +0 -9
  98. data/unittests/html/ie9_document_standards.html +0 -9
  99. data/unittests/html/iframe.html +0 -3
  100. data/unittests/html/iframeTest.html +0 -17
  101. data/unittests/html/iframeTest1.html +0 -7
  102. data/unittests/html/iframeTest2.html +0 -5
  103. data/unittests/html/images/1.gif +0 -0
  104. data/unittests/html/images/2.GIF +0 -0
  105. data/unittests/html/images/3.GIF +0 -0
  106. data/unittests/html/images/button.jpg +0 -0
  107. data/unittests/html/images/circle.jpg +0 -0
  108. data/unittests/html/images/map.GIF +0 -0
  109. data/unittests/html/images/map2.gif +0 -0
  110. data/unittests/html/images/minus.GIF +0 -0
  111. data/unittests/html/images/originaltriangle.jpg +0 -0
  112. data/unittests/html/images/plus.gif +0 -0
  113. data/unittests/html/images/square.jpg +0 -0
  114. data/unittests/html/images/triangle.jpg +0 -0
  115. data/unittests/html/images1.html +0 -65
  116. data/unittests/html/javascriptevents.html +0 -33
  117. data/unittests/html/link_pass.html +0 -11
  118. data/unittests/html/links1.html +0 -37
  119. data/unittests/html/links2.html +0 -11
  120. data/unittests/html/links_multi.html +0 -12
  121. data/unittests/html/list_matters.html +0 -720
  122. data/unittests/html/lists.html +0 -18
  123. data/unittests/html/map_test.html +0 -30
  124. data/unittests/html/modal_dialog.html +0 -10
  125. data/unittests/html/modal_dialog_launcher.html +0 -12
  126. data/unittests/html/multiple_specifiers.html +0 -64
  127. data/unittests/html/nestedFrames.html +0 -6
  128. data/unittests/html/new_browser.html +0 -17
  129. data/unittests/html/pass.html +0 -13
  130. data/unittests/html/popups1.html +0 -59
  131. data/unittests/html/pre.html +0 -29
  132. data/unittests/html/quirks_document_standards.html +0 -8
  133. data/unittests/html/radioButtons1.html +0 -71
  134. data/unittests/html/select_tealeaf.html +0 -54
  135. data/unittests/html/selectboxes1.html +0 -52
  136. data/unittests/html/simple_table.html +0 -25
  137. data/unittests/html/simple_table_buttons.html +0 -104
  138. data/unittests/html/simple_table_columns.html +0 -75
  139. data/unittests/html/table1.html +0 -179
  140. data/unittests/html/tableCell_using_xpath.html +0 -19
  141. data/unittests/html/table_and_tablerow_to_a.html +0 -174
  142. data/unittests/html/textarea.html +0 -30
  143. data/unittests/html/textfields1.html +0 -100
  144. data/unittests/html/textsearch.html +0 -44
  145. data/unittests/html/wallofcheckboxes.html +0 -1003
  146. data/unittests/html/xpath_nbsp.html +0 -11
  147. data/unittests/html/zeroindex.html +0 -11
  148. data/unittests/ie_exists_test.rb +0 -16
  149. data/unittests/ie_mock.rb +0 -94
  150. data/unittests/ie_test.rb +0 -54
  151. data/unittests/images_test.rb +0 -156
  152. data/unittests/images_xpath_test.rb +0 -90
  153. data/unittests/index_specifier_test.rb +0 -31
  154. data/unittests/js_events_test.rb +0 -31
  155. data/unittests/links_multi_test.rb +0 -34
  156. data/unittests/links_test.rb +0 -131
  157. data/unittests/links_xpath_test.rb +0 -38
  158. data/unittests/lists_test.rb +0 -23
  159. data/unittests/map_test.rb +0 -98
  160. data/unittests/minmax_test.rb +0 -37
  161. data/unittests/navigate_test.rb +0 -38
  162. data/unittests/nbsp_xpath_test.rb +0 -16
  163. data/unittests/no_wait_test.rb +0 -28
  164. data/unittests/non_core_tests.rb +0 -12
  165. data/unittests/other/all_tests_concurrent.rb +0 -57
  166. data/unittests/other/navigate_exception_test.rb +0 -24
  167. data/unittests/other/rexml_unit_test.rb +0 -27
  168. data/unittests/other/screen_capture_test.rb +0 -53
  169. data/unittests/other/testcase_method_order_test.rb +0 -36
  170. data/unittests/other/testcase_verify_test.rb +0 -25
  171. data/unittests/other/wait_until_test.rb +0 -102
  172. data/unittests/pagecontainstext_test.rb +0 -69
  173. data/unittests/parent_child_test.rb +0 -27
  174. data/unittests/perf_test.rb +0 -20
  175. data/unittests/pre_test.rb +0 -49
  176. data/unittests/radios_test.rb +0 -181
  177. data/unittests/radios_xpath_test.rb +0 -100
  178. data/unittests/security_setting_test.rb +0 -24
  179. data/unittests/selectbox_test.rb +0 -144
  180. data/unittests/selectbox_xpath_test.rb +0 -102
  181. data/unittests/setup.rb +0 -69
  182. data/unittests/speed_settings_test.rb +0 -67
  183. data/unittests/table_cell_using_xpath_test.rb +0 -34
  184. data/unittests/table_test.rb +0 -296
  185. data/unittests/table_xpath_test.rb +0 -109
  186. data/unittests/test_tests.rb +0 -9
  187. data/unittests/textarea_test.rb +0 -92
  188. data/unittests/textarea_xpath_test.rb +0 -77
  189. data/unittests/textfield_for_ch_char_test.rb +0 -32
  190. data/unittests/textfields_test.rb +0 -184
  191. data/unittests/textfields_xpath_test.rb +0 -110
  192. data/unittests/version_test.rb +0 -15
  193. data/unittests/win32ole_so_test.rb +0 -35
  194. data/unittests/window_tests.rb +0 -10
  195. data/unittests/windows/attach_to_existing_window_test.rb +0 -52
  196. data/unittests/windows/attach_to_new_window_test.rb +0 -74
  197. data/unittests/windows/close_window_test.rb +0 -20
  198. data/unittests/windows/frame_links_test.rb +0 -23
  199. data/unittests/windows/ie-each_test.rb +0 -46
  200. data/unittests/windows/modal_dialog_test.rb +0 -95
  201. data/unittests/windows/new_process_test.rb +0 -24
  202. data/unittests/windows/new_test.rb +0 -58
  203. data/unittests/windows/open_close_test.rb +0 -19
  204. data/unittests/windows/send_keys_test.rb +0 -26
  205. data/unittests/xpath_tests.rb +0 -11
  206. data/watir-rdoc.rb +0 -7
@@ -1,11 +0,0 @@
1
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
- <!doctype html>
3
- <head>
4
- <title>Test page for xpath with nbsp</title>
5
- </head>
6
- <body>
7
- <form>
8
- <div>Hello&nbsp;world</div>
9
- </form>
10
- </body>
11
- </html>
@@ -1,11 +0,0 @@
1
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
- <html>
3
- <table id="a_table">
4
- <tr id="first"><td>alt_1 - boring text</td></tr>
5
- <tr id="second"><td>alt_2 - great text</td></tr>
6
- <tr id="third"><td>alt_1 - the best text ever<td></tr>
7
- <tr id="fourth"><td>alt_2 - okay text<td></tr>
8
- <tr id="fifth"><td>alt_1 - supreme text<td></tr>
9
- <tr id="sixth"><td>alt_2 - middle of the road text<td></tr>
10
- </table>
11
- </html>
@@ -1,16 +0,0 @@
1
- # test IE#exists?
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
- require 'unittests/setup'
5
-
6
- class TC_IENotExists < Test::Unit::TestCase
7
- def setup
8
- @ie = Watir::IE.new
9
- end
10
-
11
- def test_some_one_else_closed_it
12
- @ie.ie.quit
13
- sleep 0.3 # give it some time to close
14
- assert_false(@ie.exists?)
15
- end
16
- end
@@ -1,94 +0,0 @@
1
- # mock library for testing the IE controller
2
- require 'watir-classic'
3
-
4
- class FakeFrame
5
- def length
6
- return 0
7
- end
8
- end
9
-
10
- class FakeDoc
11
-
12
- attr_accessor :links, :all
13
-
14
- def initialize
15
- @links = ""
16
- @doc = self
17
- end
18
-
19
- def getElementsByTagName(tag)
20
- @doc.links
21
- end
22
-
23
- def frames
24
- return FakeFrame.new
25
- end
26
-
27
- def readyState
28
- return "complete"
29
- end
30
-
31
- def addLink(value)
32
- if @links.nil?
33
- @links = value
34
- else
35
- @links << value
36
- end
37
- end
38
- def location
39
- self
40
- end
41
- def url
42
- return "file://fake"
43
- end
44
- alias :href :url
45
- end
46
-
47
- class StubExplorer
48
-
49
- attr_accessor :timeToWait
50
-
51
- def initialize
52
- @timeToWait = 1
53
- @visible = $HIDE_IE
54
- @document = FakeDoc.new
55
- end
56
-
57
- def document
58
- return @document
59
- end
60
-
61
- def busy
62
- sleep @timeToWait
63
- return FALSE
64
- end
65
-
66
- def readyState
67
- return 4
68
- end
69
-
70
- def visible=(value)
71
- end
72
-
73
- def visible
74
- end
75
-
76
- end
77
-
78
- class TestIE < Watir::IE
79
-
80
- def create_browser_window
81
- @ie = StubExplorer.new
82
- end
83
-
84
- def addLink(link)
85
- @ie.document.addLink(link)
86
- end
87
-
88
- def setTimeToWait(time = 1)
89
- @ie.timeToWait = time
90
- end
91
-
92
- def goto(url)
93
- end
94
- end
@@ -1,54 +0,0 @@
1
- # Unit Test for Internet Explorer
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
- require 'unittests/setup'
5
- require 'unittests/ie_mock'
6
-
7
- class TC_ie < Test::Unit::TestCase
8
- include Watir::Exception
9
-
10
- def setup
11
- @faked_ie = TestIE.new
12
- end
13
-
14
- def test_waitForIE
15
- wait_time = 1
16
- # @faked_ie.logger.level = Logger::DEBUG
17
-
18
- @faked_ie.setTimeToWait wait_time
19
- begin_time = Time.now
20
- @faked_ie.wait
21
- elapsed_time = Time.now - begin_time
22
- assert_in_delta(wait_time, elapsed_time, 0.5)
23
- end
24
-
25
- def test_getLink_ByIndexReturnsNilOnNoLinks
26
- assert_false(@faked_ie.link(:index, 0).exists?)
27
- end
28
-
29
- def test_getLink_ByBadHow
30
- @faked_ie.addLink "foo"
31
- assert_raise(UnknownObjectException) do
32
- @faked_ie.link(:no_such_mechanism, "verifying error handling").click
33
- end
34
- end
35
-
36
- def test_execute_script
37
- script = %q[
38
- var x = 'something';
39
- var y = " else";
40
- x + y;
41
- ]
42
- assert_equal "something else", browser.execute_script(script)
43
- end
44
-
45
- def test_getLink_ByUrlReturnsNilOnNoLinks
46
- assert_false(@faked_ie.link(:url, "whatever").exists?)
47
- end
48
-
49
- def test_getLink_ByTextReturnsNilOnNoLinks
50
- assert_false(@faked_ie.link(:text, "whatever").exists?)
51
- end
52
-
53
- end
54
-
@@ -1,156 +0,0 @@
1
- # feature tests for Images
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
- require 'unittests/setup'
5
- require 'ftools'
6
- require 'webrick'
7
- require 'watir-classic/cookiemanager'
8
-
9
- class TC_Images < Test::Unit::TestCase
10
- tags :must_be_visible, :creates_windows
11
- include Watir
12
-
13
- def setup
14
- goto_page "images1.html"
15
- @saved_img_path = build_path("sample.img.dat");
16
- clean_saved_image
17
- end
18
-
19
- def teardown
20
- clean_saved_image
21
- end
22
-
23
- def test_imageExists
24
- assert( ! browser.image(:name , "missing_name").exists? )
25
- assert( browser.image(:name , "circle").exists? )
26
- assert( browser.image(:name , /circ/ ).exists? )
27
-
28
- assert( ! browser.image(:id , "missing_id").exists? )
29
- assert( browser.image(:id , "square").exists? )
30
- assert( browser.image(:id , /squ/ ).exists? )
31
-
32
- assert( ! browser.image(:src, "missingsrc.gif").exists? )
33
-
34
- assert( browser.image(:src, "file:///#{$myDir}/html/images/triangle.jpg").exists? )
35
- assert( browser.image(:src , /triangle/ ).exists? )
36
-
37
- assert( browser.image(:alt , "circle" ).exists? )
38
- assert( browser.image(:alt , /cir/ ).exists? )
39
-
40
- assert( ! browser.image(:alt , "triangle" ).exists? )
41
- assert( ! browser.image(:alt , /tri/ ).exists? )
42
-
43
- assert( browser.image(:title, 'square_image').exists? )
44
- assert( ! browser.image(:title, 'pentagram').exists? )
45
- end
46
-
47
- def test_image_click
48
- assert_raises(UnknownObjectException) { browser.image(:name, "no_image_with_this").click }
49
- assert_raises(UnknownObjectException) { browser.image(:id, "no_image_with_this").click }
50
- assert_raises(UnknownObjectException) { browser.image(:src, "no_image_with_this").click}
51
- assert_raises(UnknownObjectException) { browser.image(:alt, "no_image_with_this").click}
52
-
53
- # test for bug 1882
54
- browser.text_field(:name , "text1").clear
55
- browser.button(:value , /Pos/ ).click
56
- assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
57
-
58
- # test for disabled button
59
- assert( ! browser.image(:name , 'disabler_test').disabled )
60
- browser.button(:name , 'disable_img').click
61
-
62
- assert( browser.image(:name , 'disabler_test').disabled )
63
- browser.button(:name , 'disable_img').click
64
-
65
- browser.image(:src, /button/).click
66
- assert(browser.text.include?("PASS") )
67
- end
68
-
69
- def test_imageHasLoaded
70
- assert_raises(UnknownObjectException) { browser.image(:name, "no_image_with_this").hasLoaded? }
71
- assert_raises(UnknownObjectException) { browser.image(:id, "no_image_with_this").hasLoaded? }
72
- assert_raises(UnknownObjectException) { browser.image(:src, "no_image_with_this").hasLoaded? }
73
- assert_raises(UnknownObjectException) { browser.image(:alt, "no_image_with_this").hasLoaded? }
74
-
75
- assert( ! browser.image(:name, "themissingimage").hasLoaded? )
76
- assert( browser.image(:name, "circle").hasLoaded? )
77
-
78
- assert( browser.image(:alt, "circle").hasLoaded? )
79
- assert( browser.image(:alt, /cir/ ).hasLoaded? )
80
- end
81
-
82
- def test_image_properties
83
- assert_raises(UnknownObjectException) { browser.image(:name, "no_image_with_this").hasLoaded? }
84
- assert_raises(UnknownObjectException) { browser.image(:id, "no_image_with_this").hasLoaded? }
85
- assert_raises(UnknownObjectException) { browser.image(:src, "no_image_with_this").hasLoaded? }
86
- assert_raises(UnknownObjectException) { browser.image(:index, 82).hasLoaded? }
87
-
88
- assert_raises(UnknownObjectException) { browser.image(:index, 82).name }
89
- assert_raises(UnknownObjectException) { browser.image(:index, 82).id }
90
- assert_raises(UnknownObjectException) { browser.image(:index, 82).src }
91
- assert_raises(UnknownObjectException) { browser.image(:index, 82).value }
92
- assert_raises(UnknownObjectException) { browser.image(:index, 82).height }
93
- assert_raises(UnknownObjectException) { browser.image(:index, 82).width }
94
- assert_raises(UnknownObjectException) { browser.image(:index, 82).fileCreatedDate }
95
- assert_raises(UnknownObjectException) { browser.image(:index, 82).fileSize }
96
- assert_raises(UnknownObjectException) { browser.image(:index, 82).alt}
97
- assert_raises(UnknownObjectException) { browser.image(:index, 82).title}
98
-
99
- assert_equal( "" , browser.image(:index, 1).name )
100
- assert_equal( "square" , browser.image(:index, 1).id )
101
- assert_match( /square\.jpg/i ,browser.image(:index, 1).src )
102
- assert_equal( "" , browser.image(:index, 1).value )
103
- assert_equal( 88 , browser.image(:index, 1).height )
104
- assert_equal( 88 , browser.image(:index, 1).width )
105
-
106
- # this line fails, as the date is when it is installed on the local oc, not the date the file was really created
107
- #assert_equal( "03/10/2005" , browser.image(:index, 2).fileCreatedDate )
108
- assert_equal( 788, browser.image(:index, 1).fileSize )
109
-
110
- # tool tips: alt text + title
111
- assert_equal('circle' , browser.image(:index, 5).alt)
112
- assert_equal( "" , browser.image(:index, 1).alt)
113
- assert_equal('square_image', browser.image(:id, 'square').title)
114
-
115
- # TODO: to string tests -- output should be verified!
116
- browser.image(:name , "circle").to_s
117
- browser.image(:index , 1).to_s
118
- end
119
-
120
- def test_image_iterator
121
- assert_equal(6 , browser.images.length)
122
- assert_equal("" , browser.images[1].name )
123
- assert_equal("square", browser.images[1].id )
124
- assert_match(/square/, browser.images[1].src )
125
-
126
- index = 0
127
- browser.images.each do |i|
128
- assert_equal( browser.image(:index, index).id , i.id )
129
- assert_equal( browser.image(:index, index).name , i.name )
130
- assert_equal( browser.image(:index, index).src , i.src )
131
- assert_equal( browser.image(:index, index).height , i.height )
132
- assert_equal( browser.image(:index, index).width , i.width )
133
-
134
- index += 1
135
- end
136
- assert_equal(index, browser.images.length)
137
- end
138
-
139
- def test_save_local_image
140
- browser.images[1].save(build_windows_path("sample.img.dat"))
141
- assert(File.compare(@saved_img_path, browser.images[1].src.gsub(/^file:\/\/\//, '')))
142
- end
143
-
144
- def clean_saved_image
145
- File.delete(@saved_img_path) if (File.exists?(@saved_img_path))
146
- end
147
-
148
- def build_windows_path(part)
149
- build_path(part).gsub(/\//, "\\")
150
- end
151
-
152
- def build_path(part)
153
- "#{$myDir}/#{part}"
154
- end
155
- end
156
-
@@ -1,90 +0,0 @@
1
- # feature tests for Images
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
- require 'unittests/setup'
5
- require 'ftools'
6
- require 'webrick'
7
- require 'watir-classic/cookiemanager'
8
-
9
- class TC_Images_XPath < Test::Unit::TestCase
10
- include Watir
11
-
12
- def setup
13
- gotoImagePage
14
- end
15
-
16
- def gotoImagePage
17
- goto_page "images1.html"
18
- end
19
-
20
- def test_imageExists
21
- assert_false( browser.image(:xpath , "//img[@name='missing_name']/").exists? )
22
- assert( browser.image(:xpath , "//img[@name='circle']/").exists? )
23
- # assert( browser.image(:name , /circ/ ).exists? )
24
-
25
- assert_false( browser.image(:xpath , "//img[@id='missing_id']/").exists? )
26
- assert( browser.image(:xpath , "//img[@id='square']/").exists? )
27
- # assert( browser.image(:id , /squ/ ).exists? )
28
-
29
- assert_false( browser.image(:xpath , "//img[@src='missingsrc.gif']/").exists? )
30
-
31
- # BP -- This fails for me but not for Paul. It doesn't make sense to me that it should pass.
32
- # assert( browser.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
33
- # assert( browser.image(:src , /triangle/ ).exists? )
34
-
35
- assert( browser.image(:alt , "circle" ).exists? )
36
- # assert( browser.image(:alt , /cir/ ).exists? )
37
-
38
- assert_false( browser.image(:alt , "triangle" ).exists? )
39
- # assert_false( browser.image(:alt , /tri/ ).exists? )
40
- end
41
-
42
- def test_image_click
43
- assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']/").click }
44
- assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']/").click }
45
- assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']/").click}
46
- assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']/").click}
47
-
48
- # test for bug 1882
49
- browser.text_field(:name , "text1").clear
50
- browser.button(:value , /Pos/ ).click
51
- assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
52
-
53
- # test for disabled button
54
- # assert_false( browser.image(:name , 'disabler_test').disabled )
55
- # browser.button(:name , 'disable_img').click
56
-
57
- # assert( browser.image(:name , 'disabler_test').disabled )
58
- # browser.button(:name , 'disable_img').click
59
-
60
- # browser.image(:src, /button/).click
61
- # assert(browser.text.include?("PASS") )
62
-
63
- end
64
-
65
-
66
-
67
- def test_imageHasLoaded
68
- assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']/").hasLoaded? }
69
- assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']/").hasLoaded? }
70
- assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']/").hasLoaded? }
71
- assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']/").hasLoaded? }
72
-
73
- assert_false( browser.image(:xpath , "//img[@name='themissingimage']/").hasLoaded? )
74
- assert( browser.image(:xpath , "//img[@name='circle']/").hasLoaded? )
75
-
76
- assert( browser.image(:xpath , "//img[@alt='circle']/").hasLoaded? )
77
- # assert( browser.image(:alt, /cir/ ).hasLoaded? )
78
- end
79
-
80
- def test_image_properties
81
- assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']/").hasLoaded? }
82
- assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']/").hasLoaded? }
83
- assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']/").hasLoaded? }
84
-
85
- # to string tests -- output should be verified!
86
- puts browser.image(:xpath , "//img[@name='circle']/").to_s
87
- end
88
-
89
- end
90
-
@@ -1,31 +0,0 @@
1
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
- require 'unittests/setup'
3
-
4
- class TC_BaseIndex < Test::Unit::TestCase
5
- include Watir::Exception
6
-
7
- def setup
8
- goto_page "multiple_specifiers.html"
9
- end
10
-
11
- def test_default_index
12
- assert "one", browser.table.row.cell.class_name
13
- end
14
-
15
- def test_zero_based_indexing
16
- assert "one", browser.button(:index => 0).class_name
17
- assert "two", browser.button(:index => 1).class_name
18
-
19
- Watir::IE.zero_based_indexing = false
20
-
21
- assert "one", browser.button(:index => 1).class_name
22
- assert "two", browser.button(:index => 2).class_name
23
-
24
- Watir::IE.zero_based_indexing = true
25
-
26
- assert "one", browser.button(:index => 0).class_name
27
- assert "two", browser.button(:index => 1).class_name
28
- end
29
-
30
- end
31
-