watir-classic 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. data/CHANGES +721 -0
  2. data/LICENSE +34 -0
  3. data/README.rdoc +78 -0
  4. data/VERSION +1 -0
  5. data/bin/watir-console +5 -0
  6. data/lib/watir-classic.rb +14 -0
  7. data/lib/watir-classic/IEDialog/Release/IEDialog.dll +0 -0
  8. data/lib/watir-classic/assertions.rb +44 -0
  9. data/lib/watir-classic/browser.rb +149 -0
  10. data/lib/watir-classic/browsers.rb +7 -0
  11. data/lib/watir-classic/close_all.rb +31 -0
  12. data/lib/watir-classic/container.rb +110 -0
  13. data/lib/watir-classic/contrib/enabled_popup.rb +21 -0
  14. data/lib/watir-classic/contrib/ie-new-process.rb +27 -0
  15. data/lib/watir-classic/contrib/page_checker.rb +29 -0
  16. data/lib/watir-classic/cookies.rb +80 -0
  17. data/lib/watir-classic/core.rb +43 -0
  18. data/lib/watir-classic/dialogs/file_field.rb +34 -0
  19. data/lib/watir-classic/dialogs/javascript.rb +43 -0
  20. data/lib/watir-classic/drag_and_drop_helper.rb +68 -0
  21. data/lib/watir-classic/element.rb +438 -0
  22. data/lib/watir-classic/element_collection.rb +109 -0
  23. data/lib/watir-classic/element_extensions.rb +69 -0
  24. data/lib/watir-classic/exceptions.rb +50 -0
  25. data/lib/watir-classic/form.rb +96 -0
  26. data/lib/watir-classic/frame.rb +47 -0
  27. data/lib/watir-classic/ie-class.rb +767 -0
  28. data/lib/watir-classic/ie-process.rb +47 -0
  29. data/lib/watir-classic/ie.rb +20 -0
  30. data/lib/watir-classic/image.rb +111 -0
  31. data/lib/watir-classic/input_elements.rb +480 -0
  32. data/lib/watir-classic/irb-history.rb +31 -0
  33. data/lib/watir-classic/link.rb +46 -0
  34. data/lib/watir-classic/locator.rb +243 -0
  35. data/lib/watir-classic/logger.rb +19 -0
  36. data/lib/watir-classic/matches.rb +23 -0
  37. data/lib/watir-classic/modal_dialog.rb +72 -0
  38. data/lib/watir-classic/module.rb +12 -0
  39. data/lib/watir-classic/non_control_elements.rb +114 -0
  40. data/lib/watir-classic/options.rb +56 -0
  41. data/lib/watir-classic/page-container.rb +114 -0
  42. data/lib/watir-classic/process.rb +20 -0
  43. data/lib/watir-classic/screen_capture.rb +115 -0
  44. data/lib/watir-classic/supported_elements.rb +172 -0
  45. data/lib/watir-classic/table.rb +224 -0
  46. data/lib/watir-classic/testcase.rb +97 -0
  47. data/lib/watir-classic/util.rb +35 -0
  48. data/lib/watir-classic/version.rb +4 -0
  49. data/lib/watir-classic/wait.rb +41 -0
  50. data/lib/watir-classic/wait_helper.rb +12 -0
  51. data/lib/watir-classic/waiter.rb +98 -0
  52. data/lib/watir-classic/win32.rb +40 -0
  53. data/lib/watir-classic/win32ole.rb +16 -0
  54. data/lib/watir-classic/win32ole/1.8.7/win32ole.so +0 -0
  55. data/lib/watir-classic/win32ole/1.9.3/win32ole.so +0 -0
  56. data/lib/watir-classic/window.rb +68 -0
  57. data/lib/watir-classic/xpath_locator.rb +52 -0
  58. data/rakefile.rb +54 -0
  59. data/unittests/all_tests.rb +10 -0
  60. data/unittests/buttons_xpath_test.rb +68 -0
  61. data/unittests/checkbox_test.rb +163 -0
  62. data/unittests/checkbox_xpath_test.rb +106 -0
  63. data/unittests/click_no_wait_test.rb +23 -0
  64. data/unittests/close_all_test.rb +17 -0
  65. data/unittests/core_tests.rb +17 -0
  66. data/unittests/css_selector_test.rb +44 -0
  67. data/unittests/css_test.rb +38 -0
  68. data/unittests/dialog_test.rb +64 -0
  69. data/unittests/div2_xpath_test.rb +21 -0
  70. data/unittests/div_test.rb +170 -0
  71. data/unittests/div_xpath_test.rb +95 -0
  72. data/unittests/document_standards.rb +63 -0
  73. data/unittests/element_collection_indexes_test.rb +57 -0
  74. data/unittests/element_collections_test.rb +100 -0
  75. data/unittests/element_test.rb +47 -0
  76. data/unittests/errorchecker_test.rb +31 -0
  77. data/unittests/filefield_test.rb +43 -0
  78. data/unittests/filefield_xpath_test.rb +35 -0
  79. data/unittests/form_test.rb +282 -0
  80. data/unittests/form_xpath_test.rb +254 -0
  81. data/unittests/frame_test.rb +165 -0
  82. data/unittests/google_form_test.rb +15 -0
  83. data/unittests/html/JavascriptClick.html +39 -0
  84. data/unittests/html/blankpage.html +11 -0
  85. data/unittests/html/buttons1.html +40 -0
  86. data/unittests/html/checkboxes1.html +89 -0
  87. data/unittests/html/click_no_wait.html +14 -0
  88. data/unittests/html/complex_table.html +35 -0
  89. data/unittests/html/cssTest.html +42 -0
  90. data/unittests/html/depot_store.html +59 -0
  91. data/unittests/html/div.html +92 -0
  92. data/unittests/html/div_xml.html +21 -0
  93. data/unittests/html/fileupload.html +44 -0
  94. data/unittests/html/formTest1.html +38 -0
  95. data/unittests/html/forms2.html +44 -0
  96. data/unittests/html/forms3.html +131 -0
  97. data/unittests/html/forms4.html +26 -0
  98. data/unittests/html/frame_buttons.html +4 -0
  99. data/unittests/html/frame_links.html +4 -0
  100. data/unittests/html/frame_multi.html +5 -0
  101. data/unittests/html/google_india.html +119 -0
  102. data/unittests/html/ie7_document_standards.html +9 -0
  103. data/unittests/html/ie8_document_standards.html +9 -0
  104. data/unittests/html/ie9_document_standards.html +9 -0
  105. data/unittests/html/iframe.html +3 -0
  106. data/unittests/html/iframeTest.html +17 -0
  107. data/unittests/html/iframeTest1.html +7 -0
  108. data/unittests/html/iframeTest2.html +5 -0
  109. data/unittests/html/images/1.gif +0 -0
  110. data/unittests/html/images/2.GIF +0 -0
  111. data/unittests/html/images/3.GIF +0 -0
  112. data/unittests/html/images/button.jpg +0 -0
  113. data/unittests/html/images/circle.jpg +0 -0
  114. data/unittests/html/images/map.GIF +0 -0
  115. data/unittests/html/images/map2.gif +0 -0
  116. data/unittests/html/images/minus.GIF +0 -0
  117. data/unittests/html/images/originaltriangle.jpg +0 -0
  118. data/unittests/html/images/plus.gif +0 -0
  119. data/unittests/html/images/square.jpg +0 -0
  120. data/unittests/html/images/triangle.jpg +0 -0
  121. data/unittests/html/images1.html +65 -0
  122. data/unittests/html/javascriptevents.html +33 -0
  123. data/unittests/html/link_pass.html +11 -0
  124. data/unittests/html/links1.html +37 -0
  125. data/unittests/html/links2.html +11 -0
  126. data/unittests/html/links_multi.html +12 -0
  127. data/unittests/html/list_matters.html +720 -0
  128. data/unittests/html/lists.html +18 -0
  129. data/unittests/html/map_test.html +30 -0
  130. data/unittests/html/modal_dialog.html +10 -0
  131. data/unittests/html/modal_dialog_launcher.html +12 -0
  132. data/unittests/html/multiple_specifiers.html +64 -0
  133. data/unittests/html/nestedFrames.html +6 -0
  134. data/unittests/html/new_browser.html +17 -0
  135. data/unittests/html/pass.html +13 -0
  136. data/unittests/html/popups1.html +59 -0
  137. data/unittests/html/pre.html +29 -0
  138. data/unittests/html/quirks_document_standards.html +8 -0
  139. data/unittests/html/radioButtons1.html +71 -0
  140. data/unittests/html/select_tealeaf.html +54 -0
  141. data/unittests/html/selectboxes1.html +52 -0
  142. data/unittests/html/simple_table.html +25 -0
  143. data/unittests/html/simple_table_buttons.html +104 -0
  144. data/unittests/html/simple_table_columns.html +75 -0
  145. data/unittests/html/table1.html +179 -0
  146. data/unittests/html/tableCell_using_xpath.html +19 -0
  147. data/unittests/html/table_and_tablerow_to_a.html +174 -0
  148. data/unittests/html/textarea.html +30 -0
  149. data/unittests/html/textfields1.html +100 -0
  150. data/unittests/html/textsearch.html +44 -0
  151. data/unittests/html/wallofcheckboxes.html +1003 -0
  152. data/unittests/html/xpath_nbsp.html +11 -0
  153. data/unittests/html/zeroindex.html +11 -0
  154. data/unittests/ie_exists_test.rb +16 -0
  155. data/unittests/ie_mock.rb +94 -0
  156. data/unittests/ie_test.rb +54 -0
  157. data/unittests/images_test.rb +156 -0
  158. data/unittests/images_xpath_test.rb +90 -0
  159. data/unittests/index_specifier_test.rb +31 -0
  160. data/unittests/js_events_test.rb +31 -0
  161. data/unittests/links_multi_test.rb +34 -0
  162. data/unittests/links_test.rb +131 -0
  163. data/unittests/links_xpath_test.rb +38 -0
  164. data/unittests/lists_test.rb +23 -0
  165. data/unittests/map_test.rb +98 -0
  166. data/unittests/minmax_test.rb +37 -0
  167. data/unittests/navigate_test.rb +38 -0
  168. data/unittests/nbsp_xpath_test.rb +16 -0
  169. data/unittests/no_wait_test.rb +28 -0
  170. data/unittests/non_core_tests.rb +12 -0
  171. data/unittests/other/all_tests_concurrent.rb +57 -0
  172. data/unittests/other/navigate_exception_test.rb +24 -0
  173. data/unittests/other/rexml_unit_test.rb +27 -0
  174. data/unittests/other/screen_capture_test.rb +53 -0
  175. data/unittests/other/testcase_method_order_test.rb +36 -0
  176. data/unittests/other/testcase_verify_test.rb +25 -0
  177. data/unittests/other/wait_until_test.rb +102 -0
  178. data/unittests/pagecontainstext_test.rb +69 -0
  179. data/unittests/parent_child_test.rb +27 -0
  180. data/unittests/perf_test.rb +20 -0
  181. data/unittests/pre_test.rb +49 -0
  182. data/unittests/radios_test.rb +181 -0
  183. data/unittests/radios_xpath_test.rb +100 -0
  184. data/unittests/security_setting_test.rb +24 -0
  185. data/unittests/selectbox_test.rb +144 -0
  186. data/unittests/selectbox_xpath_test.rb +102 -0
  187. data/unittests/setup.rb +69 -0
  188. data/unittests/speed_settings_test.rb +67 -0
  189. data/unittests/table_cell_using_xpath_test.rb +34 -0
  190. data/unittests/table_test.rb +296 -0
  191. data/unittests/table_xpath_test.rb +109 -0
  192. data/unittests/test_tests.rb +9 -0
  193. data/unittests/textarea_test.rb +92 -0
  194. data/unittests/textarea_xpath_test.rb +77 -0
  195. data/unittests/textfield_for_ch_char_test.rb +32 -0
  196. data/unittests/textfields_test.rb +184 -0
  197. data/unittests/textfields_xpath_test.rb +110 -0
  198. data/unittests/version_test.rb +15 -0
  199. data/unittests/win32ole_so_test.rb +35 -0
  200. data/unittests/window_tests.rb +10 -0
  201. data/unittests/windows/attach_to_existing_window_test.rb +52 -0
  202. data/unittests/windows/attach_to_new_window_test.rb +74 -0
  203. data/unittests/windows/close_window_test.rb +20 -0
  204. data/unittests/windows/frame_links_test.rb +23 -0
  205. data/unittests/windows/ie-each_test.rb +46 -0
  206. data/unittests/windows/modal_dialog_test.rb +95 -0
  207. data/unittests/windows/new_process_test.rb +24 -0
  208. data/unittests/windows/new_test.rb +58 -0
  209. data/unittests/windows/open_close_test.rb +19 -0
  210. data/unittests/windows/send_keys_test.rb +26 -0
  211. data/unittests/xpath_tests.rb +11 -0
  212. data/watir-rdoc.rb +7 -0
  213. metadata +370 -0
@@ -0,0 +1,28 @@
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
+ require 'unittests/setup'
3
+
4
+ class TC_No_Wait_Commands < Test::Unit::TestCase
5
+ def test_fire_event_no_wait
6
+ goto_page "javascriptevents.html"
7
+ browser.text_field(:index, 0).fire_event_no_wait("onkeyup")
8
+ assert_nothing_raised{
9
+ Watir::Wait.until {browser.div(:id, 'event_name').text == 'onkeyup'}
10
+ }
11
+ end
12
+
13
+ def test_set_no_wait_text_field
14
+ goto_page "textfields1.html"
15
+ browser.text_field(:name, "text1").set_no_wait("watir IE Controller")
16
+ assert_nothing_raised{
17
+ Watir::Wait.until {browser.text_field(:name, "text1").value == "watir IE Controller"}
18
+ }
19
+ end
20
+
21
+ def test_select_no_wait_text_select_list
22
+ goto_page "selectboxes1.html"
23
+ browser.select_list(:name,'sel1').select_no_wait(/Option 1/)
24
+ assert_nothing_raised{
25
+ Watir::Wait.until {browser.select_list(:name , 'sel1').selected_options.first.text == 'Option 1'}
26
+ }
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ TOPDIR = File.join(File.dirname(__FILE__), '..')
2
+ $LOAD_PATH.unshift TOPDIR
3
+
4
+ require 'unittests/setup.rb'
5
+
6
+ Dir.chdir TOPDIR
7
+ $all_tests.each {|x| require x}
8
+
9
+ Watir::UnitTest.filter = proc do |test|
10
+ test.class.to_s !~ /xpath/i &&
11
+ test.class.tags.include?(:must_be_visible)
12
+ end
@@ -0,0 +1,57 @@
1
+ # This is an UNFINISHED attempt to run the unit tests currently.
2
+ # The work on the harness is complete.
3
+ # The problem remaining is that the tests are not thread-safe.
4
+ # It's an open question whether getting this to work would actually save any execution time.
5
+
6
+ TOPDIR = File.join(File.dirname(__FILE__), '..')
7
+ $LOAD_PATH.unshift TOPDIR
8
+ Dir.chdir TOPDIR
9
+ #(Dir["unittests/*_test.rb"] - ["unittests/popups_test.rb"]).each {|x| require x}
10
+
11
+ require 'unittests/buttons_test'
12
+ require 'unittests/checkbox_test'
13
+
14
+ require 'test/unit/testsuite'
15
+ require 'thread'
16
+ class ConcurrentTestSuite < Test::Unit::TestSuite
17
+
18
+ # Runs the tests and/or suites contained in this TestSuite.
19
+ def run(result, &progress_block)
20
+ yield(STARTED, name)
21
+ threads = []
22
+ @tests.each do |test|
23
+ threads << Thread.new do
24
+ test.run(result, &progress_block)
25
+ end
26
+ end
27
+ threads.each {|t| t.join}
28
+ yield(FINISHED, name)
29
+ end
30
+ end
31
+
32
+ # create a suite
33
+ require 'test/unit/collector/objectspace'
34
+
35
+ require 'test/unit/collector'
36
+ include Test::Unit::Collector
37
+
38
+
39
+ @filters = []
40
+ suite = ConcurrentTestSuite.new('super suite')
41
+ sub_suites = []
42
+ ::ObjectSpace.each_object(Class) do |klass|
43
+ if(Test::Unit::TestCase > klass)
44
+ puts sub_suites, klass.suite
45
+ add_suite(sub_suites, klass.suite)
46
+ end
47
+ end
48
+ sort(sub_suites).each{|s| suite << s}
49
+
50
+
51
+
52
+ # select a runner
53
+ require 'test/unit/ui/console/testrunner'
54
+ Test::Unit::UI::Console::TestRunner.run(suite)
55
+
56
+
57
+ # then subclass Test::Unit::TestSuite and override the run method to be multithreaded
@@ -0,0 +1,24 @@
1
+ # feature tests for navigation errors
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
4
+ require 'unittests/setup'
5
+ require 'watir-classic/contrib/page_checker'
6
+ # To add checkers, call the ie.add_checker method
7
+ #
8
+ # ie.
9
+
10
+ class TC_NavigateException < Test::Unit::TestCase
11
+ include Watir
12
+
13
+ def setup
14
+ browser.add_checker(PageCheckers::NAVIGATION_CHECKER)
15
+ end
16
+ def teardown
17
+ browser.disable_checker(PageCheckers::NAVIGATION_CHECKER)
18
+ end
19
+
20
+ def test_http_errors
21
+ assert_raises(NavigationException) { browser.goto('http://localhost:3001') } # Cannot find server or DNS Error
22
+ assert_raises(NavigationException) { browser.goto('http://www.fxruby.org/dfdf' ) } # HTTP 404 - File not found
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ require 'test/unit'
2
+ require 'nokogiri'
3
+
4
+ class XPathTest < Test::Unit::TestCase
5
+ def setup
6
+ file = File.open( "xpath_bug.xml" )
7
+ @doc = Nokogiri::HTML::Document.read_io(file, nil, nil, 2145)
8
+ end
9
+ def fixture xpath
10
+ matches = []
11
+
12
+ @doc.xpath(xpath).each() do |node|
13
+ matches << node
14
+ assert_equal('Add', node.text)
15
+ assert_equal('ButtonText', node['class'])
16
+ end
17
+
18
+ assert_equal(1, matches.length)
19
+ end
20
+ def test_text
21
+ fixture "//div[text()='Add' and @class='ButtonText']"
22
+ end
23
+ def test_contains
24
+ fixture "//div[contains(.,'Add') and @class='ButtonText']"
25
+ end
26
+ end
27
+
@@ -0,0 +1,53 @@
1
+ # feature tests for screen capture
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
+ require 'unittests/setup'
5
+ require 'watir-classic/screen_capture'
6
+
7
+ class TC_Capture< Test::Unit::TestCase
8
+ tags :must_be_visible
9
+ include Watir
10
+ include Watir::ScreenCapture
11
+
12
+ def setup
13
+ delete_captured_files( [ 'jpeg1.jpg' , 'jpeg2.jpg' , 'bmp1.bmp', 'bmp2.bmp' ] )
14
+ browser.goto($htmlRoot + 'buttons1.html' )
15
+ @file_list = []
16
+ end
17
+
18
+ def teardown
19
+ delete_captured_files
20
+ end
21
+
22
+ def delete_captured_files(files=nil )
23
+ files = @file_list unless files
24
+ files.each do |f|
25
+ File.delete( f) if FileTest.exists?( f)
26
+ end
27
+ end
28
+
29
+ def test_jpeg
30
+ file_name= 'jpeg1.jpg'
31
+ @file_list << file_name
32
+ screen_capture( file_name )
33
+ assert(FileTest.exist?( file_name) )
34
+
35
+ file_name= 'jpeg2.jpg'
36
+ @file_list << file_name
37
+ screen_capture( file_name , true ) # just the active window
38
+ assert(FileTest.exist?( file_name) )
39
+ end
40
+
41
+ def test_bmp
42
+ file_name= 'bmp1.bmp'
43
+ @file_list << file_name
44
+ screen_capture( file_name , false, true )
45
+ assert(FileTest.exist?( file_name ) )
46
+
47
+ file_name= 'bmp2.bmp'
48
+ @file_list << file_name
49
+ screen_capture( file_name , true , true ) # just the active window
50
+ assert(FileTest.exist?( file_name) )
51
+ end
52
+ end
53
+
@@ -0,0 +1,36 @@
1
+ # the default behavior of Test::Unit::TestCase should be to execute test
2
+ # methods in alphabetical order.
3
+ # When executed, should print "A.B.C.D.E.F.G.H.I.J.K.L.F"
4
+ # The final F is actually an expected failure:
5
+ # 1) Failure:
6
+ # default_test(TC4_No_Test_Methods)
7
+
8
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..') unless $SETUP_LOADED
9
+
10
+ require 'watir-classic/testcase'
11
+
12
+ class TC1_Alphabetical_Default < Watir::TestCase
13
+ execute :alphabetically
14
+ def test_b; print 'B'; end
15
+ def test_a; print 'A'; end
16
+ def test_d; print 'D'; end
17
+ def test_c; print 'C'; end
18
+ end
19
+
20
+ class TC2_Sequential < Watir::TestCase
21
+ def test_b; print 'E'; end
22
+ def test_a; print 'F'; end
23
+ def test_d; print 'G'; end
24
+ def test_c; print 'H'; end
25
+ end
26
+
27
+ class TC3_Alphabetical_Specified < Watir::TestCase
28
+ execute :alphabetically
29
+ def test_b; print 'J'; end
30
+ def test_a; print 'I'; end
31
+ def test_d; print 'L'; end
32
+ def test_c; print 'K'; end
33
+ end
34
+
35
+ class TC4_No_Test_Methods < Watir::TestCase
36
+ end
@@ -0,0 +1,25 @@
1
+ # 3 tests, 10 assertions, 4 failures, 0 errors
2
+
3
+ require 'watir-classic/testcase'
4
+
5
+ class VerifyTests < Watir::TestCase
6
+
7
+ def test_verify
8
+ verify true
9
+ assert true
10
+ verify false
11
+ assert true
12
+ end
13
+
14
+ def test_verify_equal
15
+ verify_equal 1, 1
16
+ verify_equal 1, 2
17
+ verify_equal 3, 4
18
+ end
19
+
20
+ def test_verify_match
21
+ verify_match /\d*/, '123'
22
+ verify_match 'foo', 'foobar'
23
+ verify_match '...', 'A'
24
+ end
25
+ end
@@ -0,0 +1,102 @@
1
+ # feature tests for wait_until
2
+ #
3
+ # Watir::Waiter is DEPRECATED! Use methods from Watir::Wait and Watir::ElementExtensions instead!
4
+ #
5
+
6
+ require 'watir-classic/testcase'
7
+ require 'watir-classic/waiter'
8
+ require 'watir-classic'
9
+ require 'spec' # gem install rspec
10
+
11
+ # used for unit testing
12
+ class MockTimeKeeper < Watir::TimeKeeper
13
+ def sleep seconds
14
+ @sleep_time += seconds
15
+ end
16
+ def now
17
+ Time.now + @sleep_time
18
+ end
19
+ end
20
+
21
+ class WaitUntilInstanceTest < Watir::TestCase
22
+
23
+ def setup
24
+ @waiter = Watir::Waiter.new
25
+ @waiter.timeout = 10.0
26
+ @mock_checkee = Spec::Mocks::Mock.new "mock_checkee"
27
+
28
+ # remove this line to test with actual TimeKeeper intead of the Mock
29
+ # (slower, but more accurate)
30
+ @waiter.timer = MockTimeKeeper.new
31
+ end
32
+
33
+ def teardown
34
+ @mock_checkee.__verify if @test_passed
35
+ end
36
+
37
+ # Instance Method
38
+
39
+ def test_no_time_passes_if_true
40
+ @waiter.wait_until {true}
41
+ @waiter.timer.sleep_time.should_equal 0.0
42
+ end
43
+
44
+ def test_three_tries_before_true
45
+ @mock_checkee.should_receive(:check).exactly(3).times.and_return [false, false, true]
46
+ @waiter.wait_until {@mock_checkee.check}
47
+ @waiter.timer.sleep_time.should_equal 1.0
48
+ end
49
+
50
+ def test_timeout
51
+ @mock_checkee.should_receive(:check).any_number_of_times.and_return false
52
+ lambda{@waiter.wait_until {@mock_checkee.check}}.should_raise Watir::Exception::TimeOutException
53
+ @waiter.timer.sleep_time.should_be_close 10.25, 0.26
54
+ @waiter.timer.sleep_time.should_satisfy {|x| [10.0, 10.5].include? x}
55
+ end
56
+
57
+ def test_polling_interval
58
+ @waiter.polling_interval = 0.1
59
+ @mock_checkee.should_receive(:check).any_number_of_times.and_return false
60
+ lambda{@waiter.wait_until {@mock_checkee.check}}.should_raise Watir::Exception::TimeOutException
61
+ @waiter.timer.sleep_time.should_be_close 10.05, 0.07
62
+ end
63
+
64
+ def test_timeout_duration
65
+ @mock_checkee.should_receive(:check).any_number_of_times.and_return false
66
+ begin
67
+ @waiter.wait_until {@mock_checkee.check}
68
+ flunk
69
+ rescue Watir::Exception::TimeOutException => e
70
+ e.duration.should_be_close 10.25, 0.26
71
+ e.timeout.should_equal 10.0
72
+ end
73
+ end
74
+ end
75
+
76
+ class WaitUntilClassTest < Watir::TestCase
77
+
78
+ def setup
79
+ @mock_checkee = Spec::Mocks::Mock.new "mock_checkee"
80
+ @mock_checkee.should_receive(:check).exactly(3).times.and_return [false, false, true]
81
+ end
82
+
83
+ def teardown
84
+ @mock_checkee.__verify if @test_passed
85
+ end
86
+ # Class method
87
+
88
+ def test_class_method_with_args
89
+ Watir::Waiter.wait_until(5, 0.1) {@mock_checkee.check}
90
+ end
91
+
92
+ def test_class_method_with_defaults
93
+ Watir::Waiter.wait_until {@mock_checkee.check}
94
+ end
95
+
96
+ include Watir
97
+ def test_watir_classic_method
98
+ wait_until {@mock_checkee.check}
99
+ end
100
+
101
+ end
102
+
@@ -0,0 +1,69 @@
1
+ # feature tests for IE::contains_text
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
+ require 'unittests/setup'
5
+
6
+ class TC_contains_text < Test::Unit::TestCase
7
+
8
+ def setup
9
+ goto_page "textsearch.html"
10
+ end
11
+
12
+ def test_text_found
13
+ assert(browser.contains_text('slings and arrows of outrageous fortune'))
14
+ end
15
+
16
+ def test_text_not_found
17
+ assert_false(browser.contains_text('So are they all, all honourable men'))
18
+ end
19
+
20
+ def test_regexp_found
21
+ assert(browser.contains_text(/bodkin.*fardels/))
22
+ end
23
+
24
+ def test_regexp_not_found
25
+ assert_false(browser.contains_text(/winding.*watch.*wit/))
26
+ end
27
+
28
+ def test_match_regexp_found
29
+ $~ = browser.contains_text(/Messages ([0-9]+)/)
30
+ assert_equal('42', $1)
31
+ end
32
+
33
+ def test_bad_search_argument
34
+ assert_raises(ArgumentError) do
35
+ browser.contains_text
36
+ end
37
+ assert_raises(ArgumentError) do
38
+ browser.contains_text(nil)
39
+ end
40
+ assert_raises(ArgumentError) do
41
+ browser.contains_text(42)
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+ class TC_contains_text_in_new_ie < Test::Unit::TestCase
48
+ tags :fails_on_firefox
49
+ # Doesn't actually raise an error, but fails to close the window afterwards
50
+ # http://jira.openqa.org/browse/WTR-265
51
+ def setup
52
+ @new_browser = Watir::Browser.new
53
+ end
54
+ def test_nothing_raised
55
+ assert_nothing_raised {@new_browser.text.include? ''}
56
+ end
57
+ def teardown
58
+ @new_browser.close
59
+ end
60
+ end
61
+
62
+ class TC_contains_text_in_frame < Test::Unit::TestCase
63
+ def setup
64
+ goto_page "frame_links.html"
65
+ end
66
+ def test_in_frame
67
+ assert browser.frame(:name => 'linkFrame').contains_text('The button is really a link')
68
+ end
69
+ end
@@ -0,0 +1,27 @@
1
+ # feature tests for relative navigation/specification
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
+ require 'unittests/setup'
5
+
6
+ class TC_Relative < Test::Unit::TestCase
7
+
8
+ def setup
9
+ goto_page "depot_store.html"
10
+ @headline = browser.h3(:text, 'Pragmatic Version Control')
11
+ end
12
+
13
+ tag_method :test_parent, :fails_on_firefox
14
+ def test_parent
15
+ catalog_entry = @headline.parent
16
+ link = catalog_entry.link(:class, 'addtocart')
17
+ assert_equal 'http://localhost:3000/store/add_to_cart/12', link.href
18
+ assert_nothing_raised{link.click}
19
+ end
20
+
21
+ tag_method :test_parent_page_container, :fails_on_firefox
22
+ def test_parent_page_container
23
+ catalog_entry = @headline.parent
24
+ assert_not_nil catalog_entry.page_container
25
+ end
26
+
27
+ end