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
data/LICENSE ADDED
@@ -0,0 +1,34 @@
1
+ ---------------------------------------------------------------------------
2
+ Copyright (c) 2004 - 2006, Paul Rogers
3
+ Copyright (c) 2006 - 2007, Angrez Singh
4
+ Copyright (c) 2004 - 2010, Bret Pettichord
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions are met:
9
+
10
+ 1. Redistributions of source code must retain the above copyright notice,
11
+ this list of conditions and the following disclaimer.
12
+
13
+ 2. Redistributions in binary form must reproduce the above copyright
14
+ notice, this list of conditions and the following disclaimer in the
15
+ documentation and/or other materials provided with the distribution.
16
+
17
+ 3. Neither the names Paul Rogers, nor Bret Pettichord, nor Angrez Singh nor the names of any
18
+ other contributors to this software may be used to endorse or promote
19
+ products derived from this software without specific prior written
20
+ permission.
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
23
+ IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
26
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29
+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+ --------------------------------------------------------------------------
34
+ (based on BSD Open Source License)
@@ -0,0 +1,78 @@
1
+ = Watir Classic
2
+
3
+ Watir, pronounced water, is an open-source (BSD) family of Ruby libraries for automating web browsers. It supports your app no matter what technology it is developed in. They support Internet Explorer on Windows, Firefox and Chrome on Windows, Mac and Linux and Safari on Mac.
4
+
5
+ Project Home:: http://watir.com
6
+ Source Code:: http://github.com/bret/watir
7
+ Support:: http://watir.com/support
8
+ Gem:: https://rubygems.org/gems/watir
9
+ Gem:: https://rubygems.org/gems/firewatir
10
+ Gem:: https://rubygems.org/gems/commonwatir
11
+ Gem:: https://rubygems.org/gems/safariwatir
12
+ Gem:: https://rubygems.org/gems/watir-webdriver
13
+ Gem:: https://rubygems.org/gems/celerity
14
+
15
+ == Install
16
+
17
+ You have to install Ruby and RubyGems first. To be able to drive Firefox you have to install Firefox add-on. Detailed installation instructions are at http://watir.com/installation
18
+
19
+ === Windows
20
+
21
+ To install Internet Explorer and Firefox driver:
22
+
23
+ gem update --system
24
+ gem install watir-classic
25
+
26
+ == Examples
27
+
28
+ Some examples from http://watir.com/examples
29
+
30
+ Loading Watir gem to drive Internet Explorer on Windows
31
+
32
+ require 'watir-classic'
33
+
34
+ Starting a new browser & and going to our site
35
+
36
+ browser = Watir::Browser.new
37
+ browser.goto("http://bit.ly/watir-example")
38
+
39
+ Setting a text field
40
+
41
+ browser.text_field(:name => "entry.0.single").set "Watir"
42
+
43
+ Setting a multi-line text box
44
+
45
+ browser.text_field(:name => "entry.1.single").set "I come here from Australia. \n The weather is great here."
46
+
47
+ Setting and clearing a radio button
48
+
49
+ browser.radio(:value => "Watir").set
50
+ browser.radio(:value => "Watir").clear
51
+
52
+ Setting and clearing check boxes
53
+
54
+ browser.checkbox(:value => "Ruby").set
55
+ browser.checkbox(:value => "Python").set
56
+ browser.checkbox(:value => "Python").clear
57
+
58
+ Clicking a button
59
+
60
+ browser.button(:name => "logon").click
61
+
62
+ Clearing, getting and selecting selection list values
63
+
64
+ browser.select_list(:name => "entry.6.single").clear
65
+ puts browser.select_list(:name => "entry.6.single").options
66
+ browser.select_list(:name => "entry.6.single").select "Chrome"
67
+
68
+ Clicking a button
69
+
70
+ browser.button(:name => "submit").click
71
+
72
+ Checking for text in a page
73
+
74
+ puts browser.text.include?("Your response has been recorded.")
75
+
76
+ Checking the title of a page
77
+
78
+ puts browser.title == "Thanks!"
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.0.0
@@ -0,0 +1,5 @@
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"
@@ -0,0 +1,14 @@
1
+ #--
2
+ # The 'watir-classic' library loads the common watir-classic code, common to all watir-classic
3
+ # implementations. The 'watir-classic/browser' library will autoload the actual
4
+ # implementations.
5
+
6
+ require 'watir-classic/version'
7
+ require 'watir-classic/waiter' # this will be removed in some future version
8
+ require 'watir-classic/wait'
9
+ require 'watir-classic/wait_helper'
10
+ require 'watir-classic/element_extensions'
11
+ require 'watir-classic/util'
12
+ require 'watir-classic/exceptions'
13
+ require 'watir-classic/matches'
14
+ require 'watir-classic/browser'
@@ -0,0 +1,44 @@
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
@@ -0,0 +1,149 @@
1
+ # watir-classic/browser
2
+ require 'watir-classic/options'
3
+ module Watir
4
+
5
+ =begin rdoc
6
+
7
+ Watir is a family of open-source drivers for automating web browsers. You
8
+ can use it to write tests that are easy to read and maintain.
9
+
10
+ Watir drives browsers the same way people do. It clicks links, fills in forms,
11
+ presses buttons. Watir also checks results, such as whether expected text
12
+ appears on a page.
13
+
14
+ The Watir family currently includes support for Internet Explorer (on Windows),
15
+ Firefox (on Windows, Mac and Linux) and Safari (on Mac).
16
+
17
+ Project Homepage: http://wtr.rubyforge.org
18
+
19
+ This Browser module provides a generic interface
20
+ that tests can use to access any browser. The actual browser (and thus
21
+ the actual Watir driver) is determined at runtime based on configuration
22
+ settings.
23
+
24
+ require 'watir-classic'
25
+ browser = Watir::Browser.new
26
+ browser.goto 'http://google.com'
27
+ browser.text_field(:name, 'q').set 'pickaxe'
28
+ browser.button(:name, 'btnG').click
29
+ if browser.text.include? 'Programming Ruby'
30
+ puts 'Text was found'
31
+ else
32
+ puts 'Text was not found'
33
+ end
34
+
35
+ A comprehensive summary of the Watir API can be found here
36
+ http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
37
+
38
+ There are two ways to configure the browser that will be used by your tests.
39
+
40
+ One is to set the +watir_browser+ environment variable to +ie+ or +firefox+.
41
+ (How you do this depends on your platform.)
42
+
43
+ The other is to create a file that looks like this.
44
+
45
+ browser: ie
46
+
47
+ And then to add this line to your script, after the require statement and
48
+ before you invoke Browser.new.
49
+
50
+ Watir.options_file = 'path/to/the/file/you/just/created'
51
+
52
+ =end rdoc
53
+
54
+ module Browser
55
+ @@browser_classes = {}
56
+ @@sub_options = {}
57
+ @@default = nil
58
+ class << self
59
+
60
+ # Create a new instance of a browser driver, as determined by the
61
+ # configuration settings. (Don't be fooled: this is not actually
62
+ # an instance of Browser class.)
63
+ def new
64
+ set_sub_options
65
+ klass.new
66
+ end
67
+ # Create a new instance as with #new and start the browser on the
68
+ # specified url.
69
+ def start url
70
+ set_sub_options
71
+ klass.start url
72
+ end
73
+ # Attach to an existing browser.
74
+ def attach(how, what)
75
+ set_sub_options
76
+ klass.attach(how, what)
77
+ end
78
+ def set_options options
79
+ return unless klass.respond_to?(:set_options)
80
+ klass.set_options options
81
+ end
82
+ def options
83
+ return {} unless klass.respond_to?(:options)
84
+ klass.options
85
+ end
86
+
87
+ def klass
88
+ key = Watir.options[:browser]
89
+ eval @@browser_classes[key] # this triggers the autoload
90
+ end
91
+ private :klass
92
+ # Add support for the browser option, using the specified class,
93
+ # provided as a string. Optionally, additional options supported by
94
+ # the class can be specified as an array of symbols. Options specified
95
+ # by the user and included in this list will be passed (as a hash) to
96
+ # the set_options class method (if defined) before creating an instance.
97
+ def support hash_args
98
+ option = hash_args[:name]
99
+ class_string = hash_args[:class]
100
+ additional_options = hash_args[:options]
101
+ library = hash_args[:library]
102
+ gem = hash_args[:gem] || library
103
+
104
+ @@browser_classes[option] = class_string
105
+ @@sub_options[option] = additional_options
106
+
107
+ autoload class_string, library
108
+ activate_gem gem, option
109
+ end
110
+
111
+ def default
112
+ @@default
113
+ end
114
+ # Specifies a default browser. Must be specified before options are parsed.
115
+ def default= option
116
+ @@default = option
117
+ end
118
+ # Returns the names of the browsers that are supported by this module.
119
+ # These are the options for 'watir_browser' (env var) or 'browser:' (yaml).
120
+ def browser_names
121
+ @@browser_classes.keys
122
+ end
123
+
124
+ private
125
+ def autoload class_string, library
126
+ mod, klass = class_string.split('::')
127
+ eval "module ::#{mod}; autoload :#{klass}, '#{library}'; end"
128
+ end
129
+ # Activate the gem (if installed). The default browser will be set
130
+ # to the first gem that activates.
131
+ def activate_gem gem_name, option
132
+ begin
133
+ gem gem_name
134
+ @@default ||= option
135
+ rescue Gem::LoadError
136
+ end
137
+ end
138
+ def set_sub_options
139
+ sub_options = @@sub_options[Watir.options[:browser]]
140
+ return if sub_options.nil?
141
+ specified_options = Watir.options.reject {|k, v| !sub_options.include? k}
142
+ self.set_options specified_options
143
+ end
144
+ end
145
+ end
146
+
147
+ end
148
+
149
+ require 'watir-classic/browsers'
@@ -0,0 +1,7 @@
1
+ #--
2
+ # watir/browsers
3
+ # Define browsers supported by Watir
4
+
5
+ Watir::Browser.support :name => 'ie', :class => 'Watir::IE',
6
+ :library => 'watir-classic/ie', :gem => 'watir-classic',
7
+ :options => [:speed, :visible, :zero_based_indexing]
@@ -0,0 +1,31 @@
1
+ require 'watir-classic/ie'
2
+
3
+ module Watir
4
+ class IE
5
+ # close all ie browser windows
6
+ def self.close_all
7
+ close_all_but nil
8
+ end
9
+ # find other ie browser windows and close them
10
+ def close_others
11
+ IE.close_all_but self
12
+ end
13
+ private
14
+ def self.close_all_but(except=nil)
15
+ Watir::IE.each do |ie|
16
+ ie.close_modal
17
+ ie.close unless except and except.hwnd == ie.hwnd
18
+ end
19
+ sleep 1.0 # replace with polling for window count to be zero?
20
+ end
21
+ public
22
+ # close modal dialog. unlike IE#modal_dialog.close, does not wait for dialog
23
+ # to appear and does not raise exception if no window is found.
24
+ # returns true if modal was found and close, otherwise false
25
+ def close_modal
26
+ while self.modal_dialog.exists? do
27
+ self.modal_dialog.close
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,110 @@
1
+ module Watir
2
+ # This module contains the factory methods that are used to access most html objects
3
+ #
4
+ # For example, to access a button on a web page that has the following html
5
+ # <input type=button name='b1' value='Click Me' onClick='javascript:doSomething()'>
6
+ #
7
+ # the following watir code could be used to click the button
8
+ #
9
+ # browser.button(:name, 'b1').click
10
+ #
11
+ # or to find the name attribute
12
+ #
13
+ # browser.button(:value, 'Click Me').name
14
+ #
15
+ # there are many methods available to the Button object
16
+ #--
17
+ # Is includable for classes that have @container, document and __ole_inner_elements
18
+ module Container
19
+ include Watir::Exception
20
+
21
+ # Note: @container is the container of this object, i.e. the container
22
+ # of this container.
23
+ # In other words, for browser.table().this_thing().text_field().set,
24
+ # container of this_thing is the table.
25
+
26
+ # This is used to change the typing speed when entering text on a page.
27
+ attr_accessor :typingspeed
28
+ attr_accessor :type_keys
29
+ # The color we want to use for the active object. This can be any valid web-friendly color.
30
+ attr_accessor :activeObjectHighLightColor
31
+ # The PageContainer object containing this element
32
+ attr_accessor :page_container
33
+
34
+ def copy_test_config(container) # only used by form and frame
35
+ @typingspeed = container.typingspeed
36
+ @type_keys = container.type_keys
37
+ @activeObjectHighLightColor = container.activeObjectHighLightColor
38
+ end
39
+ private :copy_test_config
40
+
41
+ # Write the specified string to the log.
42
+ def log(what)
43
+ @container.logger.debug(what) if @logger
44
+ end
45
+
46
+ # Wait until Browser has finished loading the page.
47
+ #--
48
+ # called explicitly by most click and set methods
49
+ def wait(no_sleep=false)
50
+ @container.wait(no_sleep)
51
+ end
52
+
53
+ def set_container container #:nodoc:
54
+ @container = container
55
+ @page_container = container.page_container
56
+ end
57
+
58
+ public
59
+
60
+ def modal_dialog
61
+ ModalDialog.new(self)
62
+ end
63
+
64
+ # Searching for Page Elements
65
+ # Not for external consumption
66
+ #
67
+ #++
68
+ def __ole_inner_elements
69
+ return document.body.all
70
+ end
71
+
72
+ # This method shows the available objects on the current page.
73
+ # This is usually only used for debugging or writing new test scripts.
74
+ # This is a nice feature to help find out what HTML objects are on a page
75
+ # when developing a test case using Watir.
76
+ def show_all_objects
77
+ puts "-----------Objects in page -------------"
78
+ doc = document
79
+ s = ""
80
+ props = ["name", "id", "value", "alt", "src"]
81
+ doc.all.each do |n|
82
+ begin
83
+ s += n.invoke("type").to_s.ljust(16)
84
+ rescue
85
+ next
86
+ end
87
+ props.each do |prop|
88
+ begin
89
+ p = n.invoke(prop)
90
+ s += " " + "#{prop}=#{p}".to_s.ljust(18)
91
+ rescue
92
+ # this object probably doesnt have this property
93
+ end
94
+ end
95
+ s += "\n"
96
+ end
97
+ puts s
98
+ end
99
+
100
+ # Locator Methods
101
+ #
102
+ # Not for external use, but cannot set to private due to usages in Element
103
+ # classes.
104
+
105
+ def locator_for(locator_class, specifiers, klass)
106
+ locator_class.new self, specifiers, klass
107
+ end
108
+
109
+ end # module
110
+ end