commonwatir 1.6.5 → 1.6.6.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/CHANGES +461 -0
  2. data/{README.txt → LICENSE} +22 -48
  3. data/Rakefile +13 -11
  4. data/VERSION +1 -0
  5. data/lib/commonwatir.rb +3 -3
  6. data/lib/watir.rb +7 -6
  7. data/lib/watir/assertions.rb +44 -44
  8. data/lib/watir/browser.rb +149 -149
  9. data/lib/watir/browsers.rb +13 -12
  10. data/lib/watir/exceptions.rb +47 -47
  11. data/lib/watir/matches.rb +17 -17
  12. data/lib/watir/options.rb +53 -52
  13. data/lib/watir/testcase.rb +97 -58
  14. data/lib/watir/waiter.rb +91 -91
  15. data/unittests/attach_to_existing_window_test.rb +71 -0
  16. data/unittests/browser_test.rb +18 -0
  17. data/unittests/buttons_test.rb +224 -0
  18. data/unittests/dd_test.rb +70 -0
  19. data/unittests/dl_test.rb +68 -0
  20. data/unittests/dt_test.rb +68 -0
  21. data/unittests/element_collections_test.rb +22 -0
  22. data/unittests/em_test.rb +67 -0
  23. data/unittests/form2_test.rb +22 -0
  24. data/unittests/html/blankpage.html +12 -0
  25. data/unittests/html/buttons1.html +41 -0
  26. data/unittests/html/buttons2.html +61 -0
  27. data/unittests/html/definition_lists.html +48 -0
  28. data/unittests/html/emphasis.html +12 -0
  29. data/unittests/html/entertainment_com.html +668 -0
  30. data/unittests/html/frame_buttons.html +4 -0
  31. data/unittests/html/images/button.jpg +0 -0
  32. data/unittests/html/pass.html +10 -0
  33. data/unittests/html/phrase_elements.html +15 -0
  34. data/unittests/html/select_lists.html +18 -0
  35. data/unittests/html/utf8.html +12 -0
  36. data/unittests/html/visibility.html +90 -0
  37. data/unittests/html/watir_unit_tests.css +64 -0
  38. data/unittests/html/whitespace.html +29 -0
  39. data/unittests/inspect_test.rb +29 -0
  40. data/unittests/options.yml.example +13 -0
  41. data/unittests/select_list_test.rb +19 -0
  42. data/unittests/setup.rb +17 -0
  43. data/unittests/setup/browser.rb +14 -0
  44. data/unittests/setup/capture_io_helper.rb +17 -0
  45. data/unittests/setup/filter.rb +24 -0
  46. data/unittests/setup/lib.rb +22 -0
  47. data/unittests/setup/options.rb +29 -0
  48. data/unittests/setup/testUnitAddons.rb +8 -0
  49. data/unittests/setup/watir-unittest.rb +74 -0
  50. data/unittests/strong_test.rb +32 -0
  51. data/unittests/utf8_test.rb +24 -0
  52. data/unittests/visibility_test.rb +47 -0
  53. data/unittests/whitespace_test.rb +40 -0
  54. metadata +121 -39
  55. data/History.txt +0 -5
  56. data/Manifest.txt +0 -14
@@ -1,48 +1,22 @@
1
- = commonwatir
2
-
3
- * FIX (url)
4
-
5
- == DESCRIPTION:
6
-
7
- Common code used by Watir and FireWatir
8
-
9
- == FEATURES/PROBLEMS:
10
-
11
- * FIX (list of features or problems)
12
-
13
- == SYNOPSIS:
14
-
15
- FIX (code sample of usage)
16
-
17
- == REQUIREMENTS:
18
-
19
- * FIX (list of requirements)
20
-
21
- == INSTALL:
22
-
23
- * sudo gem install commonwatir
24
-
25
- == LICENSE:
26
-
27
- (The MIT License)
28
-
29
- Copyright (c) 2008, 2009 Bret Pettichord
30
-
31
- Permission is hereby granted, free of charge, to any person obtaining
32
- a copy of this software and associated documentation files (the
33
- 'Software'), to deal in the Software without restriction, including
34
- without limitation the rights to use, copy, modify, merge, publish,
35
- distribute, sublicense, and/or sell copies of the Software, and to
36
- permit persons to whom the Software is furnished to do so, subject to
37
- the following conditions:
38
-
39
- The above copyright notice and this permission notice shall be
40
- included in all copies or substantial portions of the Software.
41
-
42
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2008, 2009 Bret Pettichord
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,11 +1,13 @@
1
- require 'rubygems'
2
- require 'hoe'
3
- require './lib/commonwatir.rb'
4
-
5
- Hoe.spec 'commonwatir' do
6
- self.version = CommonWatir::VERSION
7
- self.rubyforge_name = 'wtr'
8
- self.developer('Bret Pettichord', 'bret@pettichord.com')
9
- self.extra_deps << ['user-choices', '>= 0']
10
- self.url = 'http://www.watir.com'
11
- end
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/gempackagetask'
5
+
6
+ task :default => :package
7
+
8
+ gemspec = eval(File.read('commonwatir.gemspec'))
9
+ Rake::GemPackageTask.new(gemspec) do |p|
10
+ p.gem_spec = gemspec
11
+ p.need_tar = false
12
+ p.need_zip = false
13
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.6.6.rc1
@@ -1,3 +1,3 @@
1
- class CommonWatir
2
- VERSION = '1.6.5'
3
- end
1
+ class CommonWatir
2
+ VERSION = '1.6.5'
3
+ end
@@ -1,6 +1,7 @@
1
- # The 'watir' library loads the common watir code, common to all watir
2
- # implementations. The 'watir/browser' library will autoload the actual
3
- # implementations.
4
-
5
- require 'watir/waiter'
6
- require 'watir/browser'
1
+ #--
2
+ # The 'watir' library loads the common watir code, common to all watir
3
+ # implementations. The 'watir/browser' library will autoload the actual
4
+ # implementations.
5
+
6
+ require 'watir/waiter'
7
+ require 'watir/browser'
@@ -1,44 +1,44 @@
1
- require 'test/unit/assertions'
2
-
3
- module Watir
4
- # Verification methods
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
+ 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,149 +1,149 @@
1
- # watir/browser
2
- require 'watir/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'
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 defined?(klass.set_options)
80
- klass.set_options options
81
- end
82
- def options
83
- return {} unless defined?(klass.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/browsers'
1
+ # watir/browser
2
+ require 'watir/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'
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/browsers'