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,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
3
- $watir_lib = File.join($root, 'watir-classic', 'lib')
4
- $libs = "-I #{$watir_lib}"
5
- exec "irb.bat #{$libs} -r rubygems -r irb/completion -r watir-classic/irb-history -r watir --simple-prompt --readline"
@@ -1,44 +0,0 @@
1
- require 'test/unit/assertions'
2
-
3
- module Watir
4
- # Verification methods used by Watir::TestCase
5
- module Assertions
6
- include Test::Unit::Assertions
7
-
8
- # Log a failure if the boolean is true. The message is the failure
9
- # message logged.
10
- # Whether true or false, the assertion count is incremented.
11
- def verify boolean, message = 'verify failed.'
12
- add_assertion
13
- add_failure message.to_s, caller unless boolean
14
- end
15
-
16
- def verify_equal expected, actual, message=nil
17
- full_message = build_message(message, <<EOT, expected, actual)
18
- <?> expected but was
19
- <?>.
20
- EOT
21
- verify(expected == actual, full_message)
22
- end
23
- def verify_match pattern, string, message=nil
24
- pattern = case(pattern)
25
- when String
26
- Regexp.new(Regexp.escape(pattern))
27
- else
28
- pattern
29
- end
30
- full_message = build_message(message, "<?> expected to be =~\n<?>.", string, pattern)
31
- verify(string =~ pattern, full_message)
32
- end
33
-
34
- end
35
-
36
- end
37
- module Test::Unit::Assertions
38
- def assert_false(boolean, message=nil)
39
- _wrap_assertion do
40
- assert_block("assert should not be called with a block.") { !block_given? }
41
- assert_block(build_message(message, "<?> is not false.", boolean)) { !boolean }
42
- end
43
- end
44
- end
@@ -1,43 +0,0 @@
1
- module Watir
2
-
3
- class JavascriptDialog
4
- WINDOW_TITLES = ['Message from webpage', 'Windows Internet Explorer','Microsoft Internet Explorer',/Mensaje de p.*/]
5
-
6
- def initialize(opts={})
7
- @opts = opts
8
- end
9
-
10
- def exists?
11
- javascript_dialog_window.exists?
12
- end
13
-
14
- def button(value)
15
- javascript_dialog_window.button(:value => value)
16
- end
17
-
18
- def close
19
- javascript_dialog_window.close
20
- end
21
-
22
- def text
23
- javascript_dialog_window.text
24
- end
25
-
26
- def javascript_dialog_window
27
- @window ||= ::RAutomation::Window.new(:title => @opts[:title] || /^(#{WINDOW_TITLES.join('|')})$/)
28
- end
29
-
30
- Watir::Container.module_eval do
31
- def javascript_dialog(opts={})
32
- JavascriptDialog.new(opts)
33
- end
34
-
35
- alias_method :dialog, :javascript_dialog
36
- end
37
- end
38
- end
39
-
40
-
41
-
42
-
43
-
@@ -1,31 +0,0 @@
1
- # snarfed from http://blog.nicksieger.com/articles/2006/04/23/tweaking-irb
2
- module Readline
3
- module History
4
- @@log ||= File.join(Dir.pwd, 'console.log')
5
-
6
- def self.log= log
7
- @@log = log
8
- end
9
-
10
- def self.write_log(line)
11
- begin
12
- File.open(@@log, 'ab') {|f| f << "#{line}\n"}
13
- rescue
14
- end
15
- end
16
-
17
- def self.start_session_log
18
- write_log("# session start: #{Time.now}")
19
- at_exit { write_log("# session stop: #{Time.now}\n") }
20
- end
21
- end
22
-
23
- alias :old_readline :readline
24
- def readline(*args)
25
- ln = old_readline(*args)
26
- History.write_log(ln)
27
- ln
28
- end
29
- end
30
-
31
- Readline::History.start_session_log
@@ -1,19 +0,0 @@
1
- module Watir
2
- class WatirLogger < Logger
3
- def initialize(filName, logsToKeep, maxLogSize)
4
- super(filName, logsToKeep, maxLogSize)
5
- self.level = Logger::DEBUG
6
- self.datetime_format = "%d-%b-%Y %H:%M:%S"
7
- self.debug("Watir starting")
8
- end
9
- end
10
-
11
- class DefaultLogger < Logger
12
- def initialize
13
- super(STDERR)
14
- self.level = Logger::WARN
15
- self.datetime_format = "%d-%b-%Y %H:%M:%S"
16
- self.info "Log started"
17
- end
18
- end
19
- end
@@ -1,115 +0,0 @@
1
-
2
- require 'Win32API'
3
-
4
- module Watir
5
- module ScreenCapture
6
-
7
- KEYEVENTF_KEYUP = 0x2
8
- SW_HIDE = 0
9
- SW_SHOW = 5
10
- SW_SHOWNORMAL = 1
11
- VK_CONTROL = 0x11
12
- VK_F4 = 0x73
13
- VK_MENU = 0x12
14
- VK_RETURN = 0x0D
15
- VK_SHIFT = 0x10
16
- VK_SNAPSHOT = 0x2C
17
- VK_TAB = 0x09
18
- GMEM_MOVEABLE = 0x0002
19
- CF_TEXT = 1
20
-
21
- # this method saves the current window or whole screen as either a bitmap or a jpeg
22
- # It uses paint to save the file, so will barf if a duplicate filename is selected, or the path doesnt exist etc
23
- # * filename - string - the name of the file to save. If its not fully qualified the current directory is used
24
- # * active_window - boolean - if true, the whole screen is captured, if false, just the active window is captured
25
- # * save_as_bmp - boolean - if true saves the file as a bitmap, saves it as a jpeg otherwise
26
- def screen_capture(filename , active_window_only=false, save_as_bmp=false)
27
-
28
-
29
- keybd_event = Win32API.new("user32", "keybd_event", ['I','I','L','L'], 'V')
30
- vkKeyScan = Win32API.new("user32", "VkKeyScan", ['I'], 'I')
31
- winExec = Win32API.new("kernel32", "WinExec", ['P','L'], 'L')
32
- openClipboard = Win32API.new('user32', 'OpenClipboard', ['L'], 'I')
33
- setClipboardData = Win32API.new('user32', 'SetClipboardData', ['I', 'I'], 'I')
34
- closeClipboard = Win32API.new('user32', 'CloseClipboard', [], 'I')
35
- globalAlloc = Win32API.new('kernel32', 'GlobalAlloc', ['I', 'I'], 'I')
36
- globalLock = Win32API.new('kernel32', 'GlobalLock', ['I'], 'I')
37
- globalUnlock = Win32API.new('kernel32', 'GlobalUnlock', ['I'], 'I')
38
- memcpy = Win32API.new('msvcrt', 'memcpy', ['I', 'P', 'I'], 'I')
39
-
40
-
41
- filename = Dir.getwd.tr('/','\\') + '\\' + filename unless filename.index('\\')
42
-
43
- if active_window_only ==false
44
- keybd_event.Call(VK_SNAPSHOT,0,0,0) # Print Screen
45
- else
46
- keybd_event.Call(VK_SNAPSHOT,1,0,0) # Alt+Print Screen
47
- end
48
-
49
- winExec.Call('mspaint.exe', SW_SHOW)
50
- sleep(1)
51
-
52
- # Ctrl + V : Paste
53
- keybd_event.Call(VK_CONTROL, 1, 0, 0)
54
- keybd_event.Call(vkKeyScan.Call(?V), 1, 0, 0)
55
- keybd_event.Call(vkKeyScan.Call(?V), 1, KEYEVENTF_KEYUP, 0)
56
- keybd_event.Call(VK_CONTROL, 1, KEYEVENTF_KEYUP, 0)
57
-
58
-
59
- # Alt F + A : Save As
60
- keybd_event.Call(VK_MENU, 1, 0, 0)
61
- keybd_event.Call(vkKeyScan.Call(?F), 1, 0, 0)
62
- keybd_event.Call(vkKeyScan.Call(?F), 1, KEYEVENTF_KEYUP, 0)
63
- keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0)
64
- keybd_event.Call(vkKeyScan.Call(?A), 1, 0, 0)
65
- keybd_event.Call(vkKeyScan.Call(?A), 1, KEYEVENTF_KEYUP, 0)
66
- sleep(1)
67
-
68
- # copy filename to clipboard
69
- hmem = globalAlloc.Call(GMEM_MOVEABLE, filename.length+1)
70
- mem = globalLock.Call(hmem)
71
- memcpy.Call(mem, filename, filename.length+1)
72
- globalUnlock.Call(hmem)
73
- openClipboard.Call(0)
74
- setClipboardData.Call(CF_TEXT, hmem)
75
- closeClipboard.Call
76
- sleep(1)
77
-
78
- # Ctrl + V : Paste
79
- keybd_event.Call(VK_CONTROL, 1, 0, 0)
80
- keybd_event.Call(vkKeyScan.Call(?V), 1, 0, 0)
81
- keybd_event.Call(vkKeyScan.Call(?V), 1, KEYEVENTF_KEYUP, 0)
82
- keybd_event.Call(VK_CONTROL, 1, KEYEVENTF_KEYUP, 0)
83
-
84
- if save_as_bmp == false
85
- # goto the combo box
86
- keybd_event.Call(VK_TAB, 1, 0, 0)
87
- keybd_event.Call(VK_TAB, 1, KEYEVENTF_KEYUP, 0)
88
- sleep(0.5)
89
-
90
- # select the first entry with J
91
- keybd_event.Call(vkKeyScan.Call(?J), 1, 0, 0)
92
- keybd_event.Call(vkKeyScan.Call(?J), 1, KEYEVENTF_KEYUP, 0)
93
- sleep(0.5)
94
- end
95
-
96
- # Enter key
97
- keybd_event.Call(VK_RETURN, 1, 0, 0)
98
- keybd_event.Call(VK_RETURN, 1, KEYEVENTF_KEYUP, 0)
99
- sleep(1)
100
-
101
- # Alt + F4 : Exit
102
- keybd_event.Call(VK_MENU, 1, 0, 0)
103
- keybd_event.Call(VK_F4, 1, 0, 0)
104
- keybd_event.Call(VK_F4, 1, KEYEVENTF_KEYUP, 0)
105
- keybd_event.Call(VK_MENU, 1, KEYEVENTF_KEYUP, 0)
106
- sleep(1)
107
-
108
- end
109
- end
110
-
111
- end
112
-
113
-
114
- #screenCapture( "f.bmp", false , true)
115
-
@@ -1,97 +0,0 @@
1
- require 'test/unit'
2
- require 'watir-classic/assertions'
3
-
4
- module Watir
5
-
6
- # This is a 'test/unit' testcase customized to exeucte test methods sequentially by default
7
- # and extra assertions
8
- #
9
- # Example Usage
10
- #
11
- # require 'watir-classic/testcase'
12
- #
13
- # class MyTestCase < Watir::TestCase
14
- #
15
- # # some helpers
16
- # @@browser = nil
17
- # def browser
18
- # @browser ||= Watir::IE.start(:url, 'http://watir.com/")
19
- # end
20
- #
21
- # # TESTS
22
- # def test_text
23
- # browser.goto "http://watir.com/"
24
- # verify_match "Web Application Testing in Ruby", browser.text
25
- # end
26
- #
27
- # def test_title
28
- # verify browser.title == 'Watir'
29
- # end
30
- #
31
- # def test_link
32
- # verify_match 'watir.com', browser.link(:text, 'Home').href
33
- # end
34
- #
35
- # def test_navigate_to_examples
36
- # browser.div(:id, 'nav').link(:text, 'Examples').click
37
- # end
38
- #
39
- # def test_url
40
- # verify_equal browser.url, 'http://watir.com/examples/'
41
- # end
42
- #
43
- # end
44
- #
45
- class TestCase < Test::Unit::TestCase
46
- include Watir::Assertions
47
- @@order = :sequentially
48
- def initialize name
49
- throw :invalid_test if name == :default_test && self.class == Watir::TestCase
50
- super
51
- end
52
- class << self
53
- attr_accessor :test_methods, :order
54
- def test_methods
55
- @test_methods ||= []
56
- end
57
- def order
58
- @order || @@order
59
- end
60
- def default_order= order
61
- @@order = order
62
- end
63
- def sorted_test_methods
64
- case order
65
- when :alphabetically then test_methods.sort
66
- when :sequentially then test_methods
67
- when :reversed_sequentially then test_methods.reverse
68
- when :reversed_alphabetically then test_methods.sort.reverse
69
- else raise ArgumentError, "Execute option not supported: #{@order}"
70
- end
71
- end
72
- def suite
73
- suite = Test::Unit::TestSuite.new(name)
74
- sorted_test_methods.each do |test|
75
- catch :invalid_test do
76
- suite << new(test)
77
- end
78
- end
79
- if (suite.empty?)
80
- catch :invalid_test do
81
- suite << new(:default_test)
82
- end
83
- end
84
- return suite
85
- end
86
- def method_added id
87
- name = id.id2name
88
- test_methods << name if name =~ /^test./
89
- end
90
- def execute order
91
- @order = order
92
- end
93
- end
94
- public :add_assertion
95
- end
96
-
97
- end
@@ -1,98 +0,0 @@
1
- #######
2
- #
3
- # Using Watir::Waiter is DEPRECATED and will be removed in some newer version of Watir! Use Watir::Wait and Watir::ElementExtensions methods instead!
4
- #
5
- #######
6
- require 'watir-classic/exceptions'
7
-
8
- module Watir
9
-
10
- def wait_until(*args)
11
- Waiter.wait_until(*args) {yield}
12
- end
13
-
14
- class TimeKeeper
15
- attr_reader :sleep_time
16
- def initialize
17
- @sleep_time = 0.0
18
- end
19
- def sleep seconds
20
- @sleep_time += Kernel.sleep seconds
21
- end
22
- def now
23
- ::Time.now
24
- end
25
- end
26
-
27
- class Waiter
28
- # This is an interface to a TimeKeeper which proxies
29
- # calls to "sleep" and "Time.now".
30
- # Useful for unit testing Waiter.
31
- attr_accessor :timer
32
-
33
- # How long to wait between each iteration through the wait_until
34
- # loop. In seconds.
35
- attr_accessor :polling_interval
36
-
37
- # Timeout for wait_until.
38
- attr_accessor :timeout
39
-
40
- @@default_polling_interval = 0.5
41
- @@default_timeout = 60.0
42
-
43
- def initialize(timeout=@@default_timeout,
44
- polling_interval=@@default_polling_interval)
45
- Kernel.warn "Using Watir::Waiter is DEPRECATED and will be removed in some newer version of Watir! Use Watir::Wait and Watir::ElementExtensions methods instead!"
46
- @timeout = timeout
47
- @polling_interval = polling_interval
48
- @timer = TimeKeeper.new
49
- end
50
-
51
- # Execute the provided block until either (1) it returns true, or
52
- # (2) the timeout (in seconds) has been reached. If the timeout is reached,
53
- # a TimeOutException will be raised. The block will always
54
- # execute at least once.
55
- #
56
- # waiter = Waiter.new(5)
57
- # waiter.wait_until {puts 'hello'}
58
- #
59
- # This code will print out "hello" for five seconds, and then raise a
60
- # Watir::TimeOutException.
61
- def wait_until # block
62
- start_time = now
63
- until yield do
64
- if (duration = now - start_time) > @timeout
65
- raise Watir::Exception::TimeOutException.new(duration, @timeout),
66
- "Timed out after #{duration} seconds."
67
- end
68
- sleep @polling_interval
69
- end
70
- end
71
-
72
- # Execute the provided block until either (1) it returns true, or
73
- # (2) the timeout (in seconds) has been reached. If the timeout is reached,
74
- # a TimeOutException will be raised. The block will always
75
- # execute at least once.
76
- #
77
- # Waiter.wait_until(5) {puts 'hello'}
78
- #
79
- # This code will print out "hello" for five seconds, and then raise a
80
- # Watir::TimeOutException.
81
-
82
- # IDEA: wait_until: remove defaults from Waiter.wait_until
83
- def self.wait_until(timeout=@@default_timeout,
84
- polling_interval=@@default_polling_interval)
85
- waiter = new(timeout, polling_interval)
86
- waiter.wait_until { yield }
87
- end
88
-
89
- private
90
- def sleep seconds
91
- @timer.sleep seconds
92
- end
93
- def now
94
- @timer.now
95
- end
96
- end
97
-
98
- end # module