commonwatir 1.6.6 → 1.6.7.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,32 @@
1
+ == Version 1.6.7 - 2010/10/21
2
+
3
+ === General improvements
4
+
5
+ * added new waiting methods on Watir::Element: #when_present, #wait_until_present and #wait_while_present (Jari Bakken and Jarmo Pertman)
6
+ * added new waiting methods on Watir::IE and Watir::Firefox: #wait_until and #wait_while (Jari Bakken and Jarmo Pertman)
7
+ * added method #present? for Watir::Element (Jari Bakken and Jarmo Pertman)
8
+ * deprecated old waiting methods in Watir::Waiter which will be removed in some future version - use Watir::Wait instead (Jarmo Pertman)
9
+
10
+ === IE improvements
11
+
12
+ * removed Watir::Simple (Željko Filipin)
13
+ * #click_no_wait was not working with frame elements. Closes http://jira.openqa.org/browse/WTR-459 (Jarmo Pertman)
14
+
15
+ === Firefox improvements
16
+
17
+ * get_attribute_value now works with attributes named something like "foo-bar" (Alan Shields)
18
+
19
+ === Cleanup & Maintenance
20
+
21
+ * cleaned up repo at GitHub
22
+ * merge licenses into one (Željko Filipin)
23
+ * Rakefile works now under non-Windows systems too (Alan Shields)
24
+ * Removed datahandler.rb
25
+
26
+
27
+ Whole Changelog is available at http://github.com/bret/watir/compare/v1.6.6...v1.6.7
28
+
29
+
1
30
  == Version 1.6.6 - 2010/10/2
2
31
 
3
32
  === IE improvements
data/LICENSE CHANGED
@@ -1,22 +1,34 @@
1
- (The MIT License)
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.
2
6
 
3
- Copyright (c) 2008, 2009 Bret Pettichord
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions are met:
4
9
 
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:
10
+ 1. Redistributions of source code must retain the above copyright notice,
11
+ this list of conditions and the following disclaimer.
12
12
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
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.
15
16
 
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.
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)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.6
1
+ 1.6.7.rc1
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+
3
+ module Watir
4
+ # This assumes that Element#visible? is defined
5
+ module ElementExtensions
6
+
7
+ #
8
+ # Wraps a {Celerity,Watir}::Element so that any subsequent method calls are
9
+ # put on hold until the element is present on the page.
10
+ #
11
+
12
+ class WhenPresentDecorator
13
+ def initialize(element, timeout)
14
+ @element = element
15
+ @timeout = timeout
16
+ end
17
+
18
+ def method_missing(m, *args, &block)
19
+ unless @element.respond_to?(m)
20
+ raise NoMethodError, "undefined method `#{m}' for #{@element.inspect}:#{@element.class}"
21
+ end
22
+
23
+ Watir::Wait.until(@timeout) { @element.present? }
24
+ @element.send(m, *args, &block)
25
+ end
26
+ end
27
+
28
+ #
29
+ # Returns true if the element exists and is visible on the page
30
+ #
31
+
32
+ def present?
33
+ exists? && visible?
34
+ end
35
+
36
+ #
37
+ # Waits until the element is present.
38
+ #
39
+ # Optional argument:
40
+ #
41
+ # timeout - seconds to wait before timing out (default: 60)
42
+ #
43
+ # browser.button(:id, 'foo').when_present.click
44
+ # browser.div(:id, 'bar').when_present { |div| ... }
45
+ # browser.p(:id, 'baz').when_present(60).text
46
+ #
47
+
48
+ def when_present(timeout = 60)
49
+ if block_given?
50
+ Watir::Wait.until(timeout) { self.present? }
51
+ yield self
52
+ else
53
+ return WhenPresentDecorator.new(self, timeout)
54
+ end
55
+ end
56
+
57
+ def wait_until_present(timeout = 60)
58
+ Watir::Wait.until(timeout) { self.present? }
59
+ end
60
+
61
+ def wait_while_present(timeout = 60)
62
+ Watir::Wait.while(timeout) { self.present? }
63
+ end
64
+
65
+ end # module ElementExtensions
66
+ end
@@ -0,0 +1,4 @@
1
+ module Watir
2
+ version_file = File.dirname(__FILE__) + '/../../VERSION'
3
+ VERSION = File.exists?(version_file) ? File.read(version_file).strip : "0.0.0"
4
+ end
data/lib/watir/wait.rb ADDED
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ module Watir
4
+ module Wait
5
+ extend self
6
+
7
+ class TimeoutError < StandardError
8
+ end
9
+
10
+ #
11
+ # Wait until the block evaluates to true or times out.
12
+ #
13
+
14
+ def until(timeout = 60, &block)
15
+ end_time = ::Time.now + timeout
16
+
17
+ until ::Time.now > end_time
18
+ result = yield(self)
19
+ return result if result
20
+ sleep 0.1
21
+ end
22
+
23
+ raise TimeoutError, "timed out after #{timeout} seconds"
24
+ end
25
+
26
+ #
27
+ # Wait while the block evaluates to true or times out.
28
+ #
29
+ def while(timeout = 60, &block)
30
+ end_time = ::Time.now + timeout
31
+
32
+ until ::Time.now > end_time
33
+ return unless yield(self)
34
+ sleep 0.1
35
+ end
36
+
37
+ raise TimeoutError, "timed out after #{timeout} seconds"
38
+ end
39
+
40
+ end # Wait
41
+ end # Watir
@@ -0,0 +1,12 @@
1
+ # include this module if there's a need to have wait_until and wait_while methods in some different scope
2
+ module Watir
3
+ module WaitHelper
4
+ def wait_until(*args, &blk)
5
+ Wait.until(*args, &blk)
6
+ end
7
+
8
+ def wait_while(*args, &blk)
9
+ Wait.while(*args, &blk)
10
+ end
11
+ end
12
+ end
data/lib/watir/waiter.rb CHANGED
@@ -1,3 +1,8 @@
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
+ #######
1
6
  require 'watir/exceptions'
2
7
 
3
8
  module Watir
@@ -37,6 +42,7 @@ class Waiter
37
42
 
38
43
  def initialize(timeout=@@default_timeout,
39
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!"
40
46
  @timeout = timeout
41
47
  @polling_interval = polling_interval
42
48
  @timer = TimeKeeper.new
data/lib/watir.rb CHANGED
@@ -3,5 +3,11 @@
3
3
  # implementations. The 'watir/browser' library will autoload the actual
4
4
  # implementations.
5
5
 
6
- require 'watir/waiter'
6
+ require 'watir/version'
7
+ require 'watir/waiter' # this will be removed in some future version
8
+ require 'watir/wait'
9
+ require 'watir/wait_helper'
10
+ require 'watir/element_extensions'
11
+ require 'watir/exceptions'
12
+ require 'watir/matches'
7
13
  require 'watir/browser'
@@ -1,5 +1,4 @@
1
1
  # feature tests for attaching to existing IE windows
2
- # revision: $Revision: 1417 $
3
2
 
4
3
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
4
  require 'unittests/setup'
@@ -1,5 +1,4 @@
1
1
  # feature tests for Buttons
2
- # revision: $Revision$
3
2
 
4
3
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
4
  require 'unittests/setup'
@@ -5,7 +5,6 @@ Test page for buttons
5
5
  </title>
6
6
  </head>
7
7
  <body>
8
- CVS Revision: $Revision $
9
8
  <br>
10
9
  Blank page to fill in the frames
11
10
  </body>
@@ -6,7 +6,6 @@ Test page for buttons
6
6
  <link rel="stylesheet" type="text/css" href="watir_unit_tests.css">
7
7
  </head>
8
8
  <body>
9
- CVS Revision: $Revision$
10
9
  <br>
11
10
  <br>
12
11
  <table>
@@ -6,7 +6,6 @@ Test page for buttons
6
6
  <link rel="stylesheet" type="text/css" href="watir_unit_tests.css">
7
7
  </head>
8
8
  <body>
9
- CVS Revision: $Revision: 1.0 $
10
9
  <br>
11
10
  <br>
12
11
  <table>
@@ -27,7 +27,6 @@
27
27
 
28
28
 
29
29
  <link rel="stylesheet" href="/consumer_site_styles.css" type="text/css" />
30
- <script language="JavaScript" src="/html/functions.js"></script>
31
30
 
32
31
  <script language="JavaScript">
33
32
  function careers_popup() {
@@ -0,0 +1,15 @@
1
+ <html>
2
+ <head>
3
+ <title>Wait Tests</title>
4
+ <script type="text/javascript">
5
+ function toggleDiv() {
6
+ var divStyle = document.getElementById('div1').style;
7
+ divStyle.display = divStyle.display == "none" ? "" : "none";
8
+ }
9
+ </script>
10
+ </head>
11
+
12
+ <div id="div1">div1</div>
13
+ <a id="link1" href="javascript:void(0)" onclick="javascript:setTimeout(toggleDiv, 500);">Click me!</a>
14
+
15
+ </html>
@@ -0,0 +1,119 @@
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
+ require 'unittests/setup'
3
+
4
+ class Wait < Test::Unit::TestCase
5
+ include Watir::Exception
6
+ location __FILE__
7
+
8
+ def setup
9
+ uses_page "wait.html"
10
+ browser.refresh
11
+ end
12
+
13
+ def test_wait_until
14
+ div = browser.div(:id => "div1")
15
+ assert div.visible?
16
+ browser.link(:id => "link1").click
17
+
18
+ browser.wait_until(2) {not div.visible?}
19
+ assert !div.visible?
20
+ end
21
+
22
+ def test_wait_until_exception
23
+ assert_raises(Watir::Wait::TimeoutError) {browser.wait_until(0.1) {false}}
24
+ end
25
+
26
+ def test_wait_while
27
+ div = browser.div(:id => "div1")
28
+ assert div.visible?
29
+ browser.link(:id => "link1").click
30
+
31
+ browser.wait_while(2) {div.visible?}
32
+ assert !div.visible?
33
+ end
34
+
35
+ def test_wait_while_exception
36
+ assert_raises(Watir::Wait::TimeoutError) {browser.wait_while(0.1) {true}}
37
+ end
38
+
39
+ def test_present?
40
+ div = browser.div(:id => "div1")
41
+ assert div.exists?
42
+ assert div.visible?
43
+ assert div.present?
44
+
45
+ browser.link(:id => "link1").click
46
+ browser.wait_until(2) {!div.visible?}
47
+ assert div.exists?
48
+ assert !div.visible?
49
+ assert !div.present?
50
+
51
+ non_existing_div = browser.div(:id => "non-existing")
52
+ assert !non_existing_div.exists?
53
+ assert_raises(Watir::Exception::UnknownObjectException) {non_existing_div.visible?}
54
+ assert !non_existing_div.present?
55
+ end
56
+
57
+ def test_when_present
58
+ browser.link(:id => "link1").click
59
+ div = browser.div(:id => "div1")
60
+ assert_equal "div1", div.when_present(2).text
61
+ assert div.visible?
62
+ end
63
+
64
+ def test_when_present_block
65
+ browser.link(:id => "link1").click
66
+ div = browser.div(:id => "div1")
67
+ div.when_present(2) do |d|
68
+ assert_equal "div1", d.text
69
+ end
70
+ assert div.visible?
71
+ end
72
+
73
+ def test_when_present_exceptions
74
+ assert_raises(NoMethodError) {browser.div(:id => "div1").when_present(0.1).non_existing_method}
75
+ assert_raises(Watir::Wait::TimeoutError) {browser.div(:id => "non-existing").when_present(0.1).text}
76
+ end
77
+
78
+ def test_wait_until_present
79
+ browser.link(:id => "link1").click
80
+
81
+ div = browser.div(:id => "div1")
82
+ browser.link(:id => "link1").click
83
+ div.wait_until_present(2)
84
+ assert div.visible?
85
+ end
86
+
87
+ def test_wait_until_present_exception
88
+ assert_raises(Watir::Wait::TimeoutError) {browser.div(:id => "non-existing").wait_until_present(0.1)}
89
+ end
90
+
91
+ def test_wait_while_present
92
+ div = browser.div(:id => "div1")
93
+ browser.link(:id => "link1").click
94
+ div.wait_while_present(2)
95
+ assert !div.visible?
96
+ end
97
+
98
+ def test_wait_while_present_exception
99
+ assert_raises(Watir::Wait::TimeoutError) {browser.div(:id => "div1").wait_while_present(0.1)}
100
+ end
101
+
102
+ def test_wait_module_until
103
+ div = browser.div(:id => "div1")
104
+ assert div.visible?
105
+ browser.link(:id => "link1").click
106
+
107
+ Watir::Wait.until(2) {not div.visible?}
108
+ assert !div.visible?
109
+ end
110
+
111
+ def test_wait_module_while
112
+ div = browser.div(:id => "div1")
113
+ assert div.visible?
114
+ browser.link(:id => "link1").click
115
+
116
+ Watir::Wait.while(2) {div.visible?}
117
+ assert !div.visible?
118
+ end
119
+ end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commonwatir
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
5
- prerelease: false
4
+ hash: 977940594
5
+ prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 6
9
- - 6
10
- version: 1.6.6
9
+ - 7
10
+ - rc1
11
+ version: 1.6.7.rc1
11
12
  platform: ruby
12
13
  authors:
13
14
  - Bret Pettichord
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-10-02 00:00:00 -06:00
19
+ date: 2010-10-21 00:00:00 -06:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -44,11 +45,15 @@ files:
44
45
  - lib/watir/assertions.rb
45
46
  - lib/watir/browser.rb
46
47
  - lib/watir/browsers.rb
48
+ - lib/watir/element_extensions.rb
47
49
  - lib/watir/exceptions.rb
48
50
  - lib/watir/matches.rb
49
51
  - lib/watir/options.rb
50
52
  - lib/watir/testcase.rb
53
+ - lib/watir/version.rb
54
+ - lib/watir/wait.rb
51
55
  - lib/watir/waiter.rb
56
+ - lib/watir/wait_helper.rb
52
57
  - lib/watir.rb
53
58
  - Rakefile
54
59
  - LICENSE
@@ -77,6 +82,7 @@ files:
77
82
  - unittests/html/select_lists.html
78
83
  - unittests/html/utf8.html
79
84
  - unittests/html/visibility.html
85
+ - unittests/html/wait.html
80
86
  - unittests/html/watir_unit_tests.css
81
87
  - unittests/html/whitespace.html
82
88
  - unittests/inspect_test.rb
@@ -93,6 +99,7 @@ files:
93
99
  - unittests/strong_test.rb
94
100
  - unittests/utf8_test.rb
95
101
  - unittests/visibility_test.rb
102
+ - unittests/wait_test.rb
96
103
  - unittests/whitespace_test.rb
97
104
  has_rdoc: true
98
105
  homepage: http://www.watir.com
@@ -116,12 +123,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
123
  required_rubygems_version: !ruby/object:Gem::Requirement
117
124
  none: false
118
125
  requirements:
119
- - - ">="
126
+ - - ">"
120
127
  - !ruby/object:Gem::Version
121
- hash: 3
128
+ hash: 25
122
129
  segments:
123
- - 0
124
- version: "0"
130
+ - 1
131
+ - 3
132
+ - 1
133
+ version: 1.3.1
125
134
  requirements: []
126
135
 
127
136
  rubyforge_project: wtr
@@ -152,6 +161,7 @@ test_files:
152
161
  - unittests/html/select_lists.html
153
162
  - unittests/html/utf8.html
154
163
  - unittests/html/visibility.html
164
+ - unittests/html/wait.html
155
165
  - unittests/html/watir_unit_tests.css
156
166
  - unittests/html/whitespace.html
157
167
  - unittests/inspect_test.rb
@@ -168,4 +178,5 @@ test_files:
168
178
  - unittests/strong_test.rb
169
179
  - unittests/utf8_test.rb
170
180
  - unittests/visibility_test.rb
181
+ - unittests/wait_test.rb
171
182
  - unittests/whitespace_test.rb