watir-webdriver 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9370b06f40fbc6975aeea6dea8986520f4bf5ecd
4
- data.tar.gz: f4cb6ecae2be21dfb1c30170e8b1aaf4aac78127
3
+ metadata.gz: 97a842500bc21408f519b175ca58df6c8533491a
4
+ data.tar.gz: 65dd8b201a511705730c8e21c6e691e615b984c6
5
5
  SHA512:
6
- metadata.gz: 398ffa48eb35503b7b92b771bf6f2a9ab6a8afc5dbfcf9033e7daaa1fcb7c69c8dcd6b4a9df55a5c3d73fb20f7a2cd7b23106e26eb4b0ac2bed8f4f34155a5c9
7
- data.tar.gz: 4966d71ac3d300392e7f8525a3f25aa81a712e7aada635632b2531cd5e57cfb52b0900f96ef0f2a141935095a251713727453301b06708474368778d3923ce89
6
+ metadata.gz: 06f2ac29fc1ba7ade5cc45b5291757fe1d6c4f907a205ddb9aaf21a78208dc603afcb3aea128ff83ac4e677378cef87f8135724559b59f9c6a699b85c8f8ff27
7
+ data.tar.gz: 01b2df0459f6fba07f5e4739e1bbd5ae3b7654c0eaf4d316725f1aa0a91c1e0e38508393d901f91f070c1994879b4cb58e555dbad9448907af08bd92fc997fdf
@@ -1,13 +1,21 @@
1
+ sudo: false
1
2
  rvm:
2
3
  - 2.0
3
4
  - 2.1
5
+ - 2.2
6
+ addons:
7
+ apt:
8
+ packages:
9
+ - unzip
10
+ - libxss1
11
+ cache: bundler
4
12
  notifications:
5
13
  recipients:
6
14
  - p0deje@gmail.com
7
15
  - jarmo.p@gmail.com
16
+ - titusfortner@gmail.com
8
17
  irc: "irc.freenode.net#watir"
9
- before_script:
10
- - support/travis.sh
18
+ before_script: support/travis.sh
11
19
  script: bundle exec rake $RAKE_TASK
12
20
  env:
13
21
  - RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=firefox
@@ -16,12 +24,7 @@ env:
16
24
  - RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=chrome
17
25
  - RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=chrome ALWAYS_LOCATE=false
18
26
  - RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=chrome PREFER_CSS=1 SELECTOR_STATS=1
19
- # - RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=phantomjs
20
- # - RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=phantomjs ALWAYS_LOCATE=false
21
- # - RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=phantomjs PREFER_CSS=1 SELECTOR_STATS=1
27
+ - RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=phantomjs
28
+ - RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=phantomjs ALWAYS_LOCATE=false
29
+ - RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=phantomjs PREFER_CSS=1 SELECTOR_STATS=1
22
30
  - RAKE_TASK=yard:doctest
23
- matrix:
24
- allow_failures:
25
- - env: RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=phantomjs
26
- - env: RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=phantomjs ALWAYS_LOCATE=false
27
- - env: RAKE_TASK=spec WATIR_WEBDRIVER_BROWSER=phantomjs PREFER_CSS=1 SELECTOR_STATS=1
data/CHANGES.md CHANGED
@@ -1,3 +1,19 @@
1
+ ### 0.9.0 (2015-10-08)
2
+
3
+ * Improve performance for Select#include? (#375, thanks @Conky5)
4
+ * Add support for waiting for elements to be enabled (#370, thanks @Rodney-QAGeek)
5
+ * Remove unnecessary wire calls for navigation (#369)
6
+ * Improve performance for Select#selected? with large drop-down lists (#367)
7
+ * Add stale element protection and correct context assurance for Browser#text (#366)
8
+ * Restore behavior for Wait#until to return result of block (#362, thanks @chrismikehogan)
9
+ * Fix context switching between frames for element collections (#361)
10
+ * AfterHooks run after closing an alert (#352)
11
+ * New AfterHooks API that deprecates Checkers:
12
+ * Use `Browser#after_hooks#add` instead of `Browser#add_checker`
13
+ * Use `Browser#after_hooks#delete` instead of `Browser#disable_checker`
14
+ * Use `Browser#after_hooks#run` instead of `Browser#run_checkers`
15
+ * Use `Browser#after_hooks#without` instead of `Browser#without_checkers`
16
+
1
17
  ### 0.8.0 (2015-06-26)
2
18
 
3
19
  * Ruby 1.8 is no longer supported. Ruby 1.9 still works, but not supported as well (#327)
data/README.md CHANGED
@@ -27,9 +27,12 @@ browser.close
27
27
  Description
28
28
  -----------
29
29
 
30
- The file in `lib/watir-webdriver/elements/html_generated.rb` is autogenerated from the HTML spec. This is done by extracting the IDL parts from the spec and processing them with the WebIDL gem (link below).
30
+ The majority of element methods Watir provides with is autogenerated from specifications.
31
+ This is done by extracting the IDL parts from the spec and processing them with the WebIDL gem (link below).
32
+ Currently supported specifications are:
31
33
 
32
- The same is true for `lib/watir-webdriver/elements/svg_elements.rb`.
34
+ * [HTML](https://www.whatwg.org/specs/web-apps/current-work/) (`lib/watir-webdriver/elements/html_generated.rb`)
35
+ * [SVG](http://www.w3.org/TR/SVG2/single-page.html) (`lib/watir-webdriver/elements/svg_generated.rb`)
33
36
 
34
37
  Specs
35
38
  -----
data/Rakefile CHANGED
@@ -121,3 +121,24 @@ end
121
121
  load "spec/watirspec/watirspec.rake" if File.exist?("spec/watirspec/watirspec.rake")
122
122
 
123
123
  task default: [:spec, 'yard:doctest']
124
+
125
+ namespace :spec do
126
+ require 'selenium-webdriver'
127
+
128
+ desc 'Run specs in all browsers'
129
+ task all_browsers: [:firefox,
130
+ :firefox_nightly,
131
+ :chrome,
132
+ (:safari if Selenium::WebDriver::Platform.os == :macosx),
133
+ (:ie if Selenium::WebDriver::Platform.os == :windows),
134
+ (:edge if Selenium::WebDriver::Platform.os == :windows),
135
+ :phantomjs].compact
136
+
137
+ %w(firefox firefox_nightly chrome safari phantomjs ie edge).each do |browser|
138
+ desc "Run specs in #{browser}"
139
+ task browser do
140
+ ENV['WATIR_WEBDRIVER_BROWSER'] = browser
141
+ Rake::Task['spec'].execute
142
+ end
143
+ end
144
+ end
@@ -18,6 +18,7 @@ require 'watir-webdriver/locators/child_row_locator'
18
18
  require 'watir-webdriver/locators/child_cell_locator'
19
19
  require 'watir-webdriver/browser'
20
20
  require 'watir-webdriver/screenshot'
21
+ require 'watir-webdriver/after_hooks'
21
22
 
22
23
  module Watir
23
24
  @always_locate = true
@@ -0,0 +1,132 @@
1
+ module Watir
2
+
3
+ #
4
+ # After hooks are blocks that run after certain browser events.
5
+ # They are generally used to ensure application under test does not encounter
6
+ # any error and are automatically executed after following events:
7
+ # 1. Open URL.
8
+ # 2. Refresh page.
9
+ # 3. Click, double-click or right-click on element.
10
+ # 4. Alert closing.
11
+ #
12
+
13
+ class AfterHooks
14
+ include Enumerable
15
+
16
+ def initialize(browser)
17
+ @browser = browser
18
+ @after_hooks = []
19
+ end
20
+
21
+ #
22
+ # Adds new after hook.
23
+ #
24
+ # @example
25
+ # browser.after_hooks.add do |browser|
26
+ # browser.text.include?("Server Error") and puts "Application exception or 500 error!"
27
+ # end
28
+ # browser.goto "www.watir.com/404"
29
+ # "Application exception or 500 error!"
30
+ #
31
+ # @param [#call] after_hook Object responding to call
32
+ # @yield after_hook block
33
+ # @yieldparam [Watir::Browser]
34
+ #
35
+
36
+ def add(after_hook = nil, &block)
37
+ if block_given?
38
+ @after_hooks << block
39
+ elsif after_hook.respond_to? :call
40
+ @after_hooks << after_hook
41
+ else
42
+ raise ArgumentError, "expected block or object responding to #call"
43
+ end
44
+ end
45
+ alias_method :<<, :add
46
+
47
+ #
48
+ # Deletes after hook.
49
+ #
50
+ # @example
51
+ # browser.after_hooks.add do |browser|
52
+ # browser.text.include?("Server Error") and puts "Application exception or 500 error!"
53
+ # end
54
+ # browser.goto "www.watir.com/404"
55
+ # "Application exception or 500 error!"
56
+ # browser.after_hooks.delete browser.after_hooks[0]
57
+ # browser.refresh
58
+ #
59
+
60
+ def delete(after_hook)
61
+ @after_hooks.delete(after_hook)
62
+ end
63
+
64
+ #
65
+ # Runs after hooks.
66
+ #
67
+
68
+ def run
69
+ if @after_hooks.any? && @browser.window.present?
70
+ each { |after_hook| after_hook.call(@browser) }
71
+ end
72
+ end
73
+
74
+ #
75
+ # Executes a block without running error after hooks.
76
+ #
77
+ # @example
78
+ # browser.after_hooks.without do |browser|
79
+ # browser.element(name: "new_user_button").click
80
+ # end
81
+ #
82
+ # @yield Block that is executed without after hooks being run
83
+ # @yieldparam [Watir::Browser]
84
+ #
85
+
86
+ def without
87
+ current_after_hooks = @after_hooks
88
+ @after_hooks = []
89
+ yield(@browser)
90
+ ensure
91
+ @after_hooks = current_after_hooks
92
+ end
93
+
94
+ #
95
+ # Yields each after hook.
96
+ #
97
+ # @yieldparam [#call] after_hook Object responding to call
98
+ #
99
+
100
+ def each
101
+ @after_hooks.each { |after_hook| yield after_hook }
102
+ end
103
+
104
+ #
105
+ # Returns number of after hooks.
106
+ #
107
+ # @example
108
+ # browser.after_hooks.add { puts 'Some after_hook.' }
109
+ # browser.after_hooks.length
110
+ # #=> 1
111
+ #
112
+ # @return [Fixnum]
113
+ #
114
+
115
+ def length
116
+ @after_hooks.length
117
+ end
118
+ alias_method :size, :length
119
+
120
+ #
121
+ # Gets the after hook at the given index.
122
+ #
123
+ # @param [Fixnum] index
124
+ # @return [#call]
125
+ #
126
+
127
+ def [](index)
128
+ @after_hooks[index]
129
+ end
130
+
131
+ end # AfterHooks
132
+ end # Watir
@@ -3,8 +3,8 @@ module Watir
3
3
 
4
4
  include EventuallyPresent
5
5
 
6
- def initialize(target_locator)
7
- @target_locator = target_locator
6
+ def initialize(browser)
7
+ @browser = browser
8
8
  @alert = nil
9
9
  end
10
10
 
@@ -35,6 +35,7 @@ module Watir
35
35
  def ok
36
36
  assert_exists
37
37
  @alert.accept
38
+ @browser.after_hooks.run
38
39
  end
39
40
 
40
41
  #
@@ -49,6 +50,7 @@ module Watir
49
50
  def close
50
51
  assert_exists
51
52
  @alert.dismiss
53
+ @browser.after_hooks.run
52
54
  end
53
55
 
54
56
  #
@@ -93,7 +95,7 @@ module Watir
93
95
  private
94
96
 
95
97
  def assert_exists
96
- @alert = @target_locator.alert
98
+ @alert = @browser.driver.switch_to.alert
97
99
  rescue Selenium::WebDriver::Error::NoAlertPresentError
98
100
  raise Exception::UnknownObjectException, 'unable to locate alert'
99
101
  end
@@ -10,6 +10,7 @@ module Watir
10
10
  include Waitable
11
11
 
12
12
  attr_reader :driver
13
+ attr_reader :after_hooks
13
14
  alias_method :wd, :driver # ensures duck typing with Watir::Element
14
15
 
15
16
  class << self
@@ -49,9 +50,9 @@ module Watir
49
50
  raise ArgumentError, "expected Symbol or Selenium::WebDriver::Driver, got #{browser.class}"
50
51
  end
51
52
 
52
- @error_checkers = []
53
+ @after_hooks = AfterHooks.new(self)
53
54
  @current_frame = nil
54
- @closed = false
55
+ @closed = false
55
56
  end
56
57
 
57
58
  def inspect
@@ -74,9 +75,9 @@ module Watir
74
75
  uri = "http://#{uri}" unless uri =~ URI.regexp
75
76
 
76
77
  @driver.navigate.to uri
77
- run_checkers
78
+ @after_hooks.run
78
79
 
79
- url
80
+ uri
80
81
  end
81
82
 
82
83
  #
@@ -169,7 +170,7 @@ module Watir
169
170
  #
170
171
 
171
172
  def text
172
- @driver.find_element(:tag_name, "body").text
173
+ body.text
173
174
  end
174
175
 
175
176
  #
@@ -190,7 +191,7 @@ module Watir
190
191
  #
191
192
 
192
193
  def alert
193
- Alert.new driver.switch_to
194
+ Alert.new(self)
194
195
  end
195
196
 
196
197
  #
@@ -199,7 +200,7 @@ module Watir
199
200
 
200
201
  def refresh
201
202
  @driver.navigate.refresh
202
- run_checkers
203
+ @after_hooks.run
203
204
  end
204
205
 
205
206
  #
@@ -281,79 +282,39 @@ module Watir
281
282
  end
282
283
 
283
284
  #
284
- # Adds new checker.
285
- #
286
- # Checkers are generally used to ensure application under test does not encounter
287
- # any error. They are automatically executed after following events:
288
- # 1. Open URL
289
- # 2. Refresh page
290
- # 3. Click, double-click or right-click on element
291
- #
292
- # @example
293
- # browser.add_checker do |page|
294
- # page.text.include?("Server Error") and puts "Application exception or 500 error!"
295
- # end
296
- # browser.goto "www.watir.com/404"
297
- # "Application exception or 500 error!"
298
- #
299
- # @param [#call] checker Object responding to call
300
- # @yield Checker block
301
- # @yieldparam [Watir::Browser]
285
+ # @deprecated Use `Watir::AfterHooks#add` instead
302
286
  #
303
287
 
304
288
  def add_checker(checker = nil, &block)
305
- if block_given?
306
- @error_checkers << block
307
- elsif checker.respond_to? :call
308
- @error_checkers << checker
309
- else
310
- raise ArgumentError, "expected block or object responding to #call"
311
- end
289
+ warn 'Browser#add_checker is deprecated. Use Browser#after_hooks#add instead.'
290
+ @after_hooks.add(checker, &block)
312
291
  end
313
292
 
314
293
  #
315
- # Deletes checker.
316
- #
317
- # @example
318
- # checker = lambda do |page|
319
- # page.text.include?("Server Error") and puts "Application exception or 500 error!"
320
- # end
321
- # browser.add_checker checker
322
- # browser.goto "www.watir.com/404"
323
- # "Application exception or 500 error!"
324
- # browser.disable_checker checker
325
- # browser.refresh
294
+ # @deprecated Use `Watir::AfterHooks#delete` instead
326
295
  #
327
296
 
328
297
  def disable_checker(checker)
329
- @error_checkers.delete(checker)
298
+ warn 'Browser#disable_checker is deprecated. Use Browser#after_hooks#delete instead.'
299
+ @after_hooks.delete(checker)
330
300
  end
331
301
 
332
302
  #
333
- # Runs checkers.
303
+ # @deprecated Use `Watir::AfterHooks#run` instead
334
304
  #
335
305
 
336
306
  def run_checkers
337
- @error_checkers.each { |e| e.call(self) } if !@error_checkers.empty? && window.present?
307
+ warn 'Browser#run_checkers is deprecated. Use Browser#after_hooks#run instead.'
308
+ @after_hooks.run
338
309
  end
339
310
 
340
311
  #
341
- # Executes a block without running error checkers.
342
- #
343
- # @example
344
- # browser.without_checkers do
345
- # browser.element(name: "new_user_button").click
346
- # end
347
- #
348
- # @yieldparam [Watir::Browser]
312
+ # @deprecated Use `Watir::AfterHooks#without` instead
349
313
  #
350
314
 
351
- def without_checkers
352
- current_checkers = @error_checkers
353
- @error_checkers = []
354
- yield(self)
355
- ensure
356
- @error_checkers = current_checkers
315
+ def without_checkers(&block)
316
+ warn 'Browser#without_checkers is deprecated. Use Browser#after_hooks#without instead.'
317
+ @after_hooks.without(&block)
357
318
  end
358
319
 
359
320
  #
@@ -87,6 +87,8 @@ module Watir
87
87
  private
88
88
 
89
89
  def elements
90
+ @parent.is_a?(IFrame) ? @parent.switch_to! : @parent.send(:assert_exists)
91
+
90
92
  @elements ||= locator_class.new(
91
93
  @parent.wd,
92
94
  @selector,
@@ -5,6 +5,7 @@ module Watir
5
5
  # Sets checkbox to the given value.
6
6
  #
7
7
  # @example
8
+ # checkbox = browser.checkbox(id: 'new_user_interests_cars')
8
9
  # checkbox.set? #=> false
9
10
  # checkbox.set
10
11
  # checkbox.set? #=> true
@@ -129,7 +129,7 @@ module Watir
129
129
  end
130
130
  end
131
131
 
132
- run_checkers
132
+ browser.after_hooks.run
133
133
  end
134
134
 
135
135
  #
@@ -145,7 +145,7 @@ module Watir
145
145
  assert_has_input_devices_for :double_click
146
146
 
147
147
  element_call { driver.action.double_click(@element).perform }
148
- run_checkers
148
+ browser.after_hooks.run
149
149
  end
150
150
 
151
151
  #
@@ -161,7 +161,7 @@ module Watir
161
161
  assert_has_input_devices_for :right_click
162
162
 
163
163
  element_call { driver.action.context_click(@element).perform }
164
- run_checkers
164
+ browser.after_hooks.run
165
165
  end
166
166
 
167
167
  #
@@ -403,6 +403,16 @@ module Watir
403
403
  element_call { @element.displayed? }
404
404
  end
405
405
 
406
+ #
407
+ # Returns true if this element is present and enabled on the page.
408
+ #
409
+ # @return [Boolean]
410
+ #
411
+
412
+ def enabled?
413
+ present? && element_call { @element.enabled? }
414
+ end
415
+
406
416
  #
407
417
  # Returns true if the element exists and is visible on the page.
408
418
  #
@@ -438,14 +448,6 @@ module Watir
438
448
  end
439
449
  end
440
450
 
441
- #
442
- # Runs checkers.
443
- #
444
-
445
- def run_checkers
446
- @parent.run_checkers
447
- end
448
-
449
451
  #
450
452
  # Cast this Element instance to a more specific subtype.
451
453
  #
@@ -10,7 +10,7 @@ module Watir
10
10
  def submit
11
11
  assert_exists
12
12
  element_call { @element.submit }
13
- run_checkers
13
+ browser.after_hooks.run
14
14
  end
15
15
 
16
16
  end # Form
@@ -45,8 +45,13 @@ module Watir
45
45
  #
46
46
 
47
47
  def include?(str_or_rx)
48
- # TODO: optimize similar to selected?
49
- options.any? { |e| str_or_rx === e.text }
48
+ assert_exists
49
+
50
+ element_call do
51
+ @element.find_elements(:tag_name, 'option').any? do |e|
52
+ str_or_rx === e.text || str_or_rx === e.attribute(:label)
53
+ end
54
+ end
50
55
  end
51
56
 
52
57
  #
@@ -86,17 +91,22 @@ module Watir
86
91
 
87
92
  def selected?(str_or_rx)
88
93
  assert_exists
89
- matches = element_call do
90
- @element.find_elements(:tag_name, 'option').select do |e|
91
- str_or_rx === e.text || str_or_rx === e.attribute(:label)
94
+
95
+ match_found = false
96
+
97
+ element_call do
98
+ @element.find_elements(:tag_name, 'option').each do |e|
99
+ matched = str_or_rx === e.text || str_or_rx === e.attribute(:label)
100
+ if matched
101
+ return true if e.selected?
102
+ match_found = true
103
+ end
92
104
  end
93
105
  end
94
106
 
95
- if matches.empty?
96
- raise UnknownObjectException, "Unable to locate option matching #{str_or_rx.inspect}"
97
- end
107
+ raise(UnknownObjectException, "Unable to locate option matching #{str_or_rx.inspect}") unless match_found
98
108
 
99
- matches.any? { |e| e.selected? }
109
+ false
100
110
  end
101
111
 
102
112
  #
@@ -1,3 +1,3 @@
1
1
  module Watir
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0'
3
3
  end
@@ -37,7 +37,10 @@ module Watir
37
37
 
38
38
  def until(timeout = nil, message = nil)
39
39
  timeout ||= Watir.default_timeout
40
- run_with_timer(timeout) { return true if yield(self) }
40
+ run_with_timer(timeout) do
41
+ result = yield(self)
42
+ return result if result
43
+ end
41
44
  raise TimeoutError, message_for(timeout, message)
42
45
  end
43
46
 
@@ -91,15 +94,7 @@ module Watir
91
94
  end
92
95
  end
93
96
 
94
- #
95
- # Wraps an Element so that any subsequent method calls are
96
- # put on hold until the element is present (exists and is visible) on the page.
97
- #
98
-
99
- class WhenPresentDecorator
100
- extend Forwardable
101
-
102
- def_delegator :@element, :present?
97
+ class BaseDecorator
103
98
 
104
99
  def initialize(element, timeout, message = nil)
105
100
  @element = element
@@ -116,12 +111,43 @@ module Watir
116
111
  raise NoMethodError, "undefined method `#{m}' for #{@element.inspect}:#{@element.class}"
117
112
  end
118
113
 
119
- Watir::Wait.until(@timeout, @message) { @element.present? }
114
+ Watir::Wait.until(@timeout, @message) { wait_until }
120
115
 
121
116
  @element.__send__(m, *args, &block)
122
117
  end
118
+ end
119
+
120
+ #
121
+ # Wraps an Element so that any subsequent method calls are
122
+ # put on hold until the element is present (exists and is visible) on the page.
123
+ #
124
+
125
+ class WhenPresentDecorator < BaseDecorator
126
+ extend Forwardable
127
+
128
+ def_delegator :@element, :present?
129
+
130
+ private
131
+
132
+ def wait_until
133
+ @element.present?
134
+ end
123
135
  end # WhenPresentDecorator
124
136
 
137
+ #
138
+ # Wraps an Element so that any subsequent method calls are
139
+ # put on hold until the element is enabled (exists and is enabled) on the page.
140
+ #
141
+
142
+ class WhenEnabledDecorator < BaseDecorator
143
+
144
+ private
145
+
146
+ def wait_until
147
+ @element.enabled?
148
+ end
149
+ end # WhenEnabledDecorator
150
+
125
151
  #
126
152
  # Convenience methods for things that eventually become present.
127
153
  #
@@ -155,6 +181,30 @@ module Watir
155
181
  end
156
182
  end
157
183
 
184
+ #
185
+ # Waits until the element is enabled.
186
+ #
187
+ # @example
188
+ # browser.button(name: "new_user_button_2").when_enabled.click
189
+ #
190
+ # @param [Fixnum] timeout seconds to wait before timing out
191
+ #
192
+ # @see Watir::Wait
193
+ # @see Watir::Element#enabled?
194
+ #
195
+
196
+ def when_enabled(timeout = nil)
197
+ timeout ||= Watir.default_timeout
198
+ message = "waiting for #{selector_string} to become enabled"
199
+
200
+ if block_given?
201
+ Watir::Wait.until(timeout, message) { enabled? }
202
+ yield self
203
+ else
204
+ WhenEnabledDecorator.new(self, timeout, message)
205
+ end
206
+ end
207
+
158
208
  #
159
209
  # Waits until the element is present.
160
210
  #
@@ -15,29 +15,5 @@ describe Watir::Element do
15
15
  expect(browser.element(text: "You Clicked It!")).to exist
16
16
  end
17
17
  end
18
-
19
- # TODO: make guards more flexible, in reality this currently only works on linux with native events
20
- compliant_on %i(webdriver firefox native_events) do
21
- it "should perform a click with no modifier keys" do
22
- clicker.click
23
- expect(log).to eq ["shift=false alt=false"]
24
- end
25
-
26
- it "should perform a click with the shift key pressed" do
27
- clicker.click(:shift)
28
- expect(log).to eq ["shift=true alt=false"]
29
- end
30
-
31
- it "should perform a click with the alt key pressed" do
32
- clicker.click(:alt)
33
- expect(log).to eq ["shift=false alt=true"]
34
- end
35
-
36
- it "should perform a click with the shift and alt keys pressed" do
37
- clicker.click(:shift, :alt)
38
- expect(log).to eq ["shift=true alt=true"]
39
- end
40
- end
41
-
42
18
  end
43
19
  end
@@ -72,7 +72,8 @@ class ImplementationConfig
72
72
  matching_browser, # guard only applies to this browser
73
73
  matching_browser_with_version, # guard only applies to this browser with specific version
74
74
  [:webdriver, matching_browser], # guard only applies to this browser on webdriver
75
- [:webdriver, matching_browser_with_version] # guard only applies to this browser with specific version on webdriver
75
+ [:webdriver, matching_browser_with_version], # guard only applies to this browser with specific version on webdriver
76
+ [matching_browser, Selenium::WebDriver::Platform.os] # guard only applies to this browser with this OS
76
77
  ]
77
78
 
78
79
  if native_events?
@@ -33,11 +33,6 @@ YARD::Doctest.configure do |doctest|
33
33
  browser.button(id: 'prompt').click
34
34
  end
35
35
 
36
- doctest.before('Watir::CheckBox#set') do
37
- browser.goto WatirSpec.url_for('forms_with_input_elements.html')
38
- checkbox = browser.checkbox(id: 'new_user_interests_cars')
39
- end
40
-
41
36
  %w[Watir::Browser#execute_script Watir::Element#drag_and_drop].each do |name|
42
37
  doctest.before(name) do
43
38
  browser.goto WatirSpec.url_for('drag_and_drop.html')
@@ -3,9 +3,6 @@
3
3
  set -e
4
4
  set -x
5
5
 
6
- export CHROME_REVISION=228611
7
- export CHROMEDRIVER_VERSION=2.9
8
-
9
6
  sh -e /etc/init.d/xvfb start
10
7
  git submodule update --init
11
8
 
@@ -13,31 +10,15 @@ mkdir ~/.yard
13
10
  bundle exec yard config -a autoload_plugins yard-doctest
14
11
 
15
12
  if [[ "$WATIR_WEBDRIVER_BROWSER" = "chrome" ]]; then
16
- sudo chmod 1777 /dev/shm
17
-
18
- sudo apt-get update
19
- sudo apt-get install -y unzip libxss1
13
+ export CHROME_REVISION=`curl -s http://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/LAST_CHANGE`
14
+ export CHROMEDRIVER_VERSION=`curl -s http://chromedriver.storage.googleapis.com/LATEST_RELEASE`
20
15
 
21
16
  curl -L -O "http://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/${CHROME_REVISION}/chrome-linux.zip"
22
17
  unzip chrome-linux.zip
23
18
 
24
- # chrome sandbox doesn't currently work on travis: https://github.com/travis-ci/travis-ci/issues/938
25
- sudo chown root:root chrome-linux/chrome_sandbox
26
- sudo chmod 4755 chrome-linux/chrome_sandbox
27
- export CHROME_DEVEL_SANDBOX="$PWD/chrome-linux/chrome_sandbox"
28
-
29
19
  curl -L -O "http://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip"
30
20
  unzip chromedriver_linux64.zip
31
21
 
32
22
  mv chromedriver chrome-linux/chromedriver
33
23
  chmod +x chrome-linux/chromedriver
34
24
  fi
35
-
36
- if [[ "$WATIR_WEBDRIVER_BROWSER" = "phantomjs" ]]; then
37
- PHANTOMJS_NAME=phantomjs-1.9.0-linux-x86_64
38
- curl -L -O "https://phantomjs.googlecode.com/files/$PHANTOMJS_NAME.tar.bz2"
39
- tar -xvjf $PHANTOMJS_NAME.tar.bz2
40
- chmod +x $PHANTOMJS_NAME/bin/phantomjs
41
- sudo cp $PHANTOMJS_NAME/bin/phantomjs /usr/local/phantomjs/bin/phantomjs
42
- phantomjs --version
43
- fi
@@ -32,5 +32,5 @@ Gem::Specification.new do |s|
32
32
  s.add_development_dependency "activesupport", "~> 3.0" # for pluralization during code generation
33
33
  s.add_development_dependency "pry"
34
34
  s.add_development_dependency "coveralls"
35
- s.add_development_dependency "yard-doctest", "0.1.4"
35
+ s.add_development_dependency "yard-doctest", "~> 0.1.5"
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir-webdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-26 00:00:00.000000000 Z
11
+ date: 2015-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -168,16 +168,16 @@ dependencies:
168
168
  name: yard-doctest
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '='
171
+ - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: 0.1.4
173
+ version: 0.1.5
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '='
178
+ - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 0.1.4
180
+ version: 0.1.5
181
181
  description: WebDriver-backed Watir
182
182
  email:
183
183
  - jari.bakken@gmail.com
@@ -195,6 +195,7 @@ files:
195
195
  - README.md
196
196
  - Rakefile
197
197
  - lib/watir-webdriver.rb
198
+ - lib/watir-webdriver/after_hooks.rb
198
199
  - lib/watir-webdriver/alert.rb
199
200
  - lib/watir-webdriver/aliases.rb
200
201
  - lib/watir-webdriver/atoms.rb
@@ -308,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
308
309
  version: '0'
309
310
  requirements: []
310
311
  rubyforge_project: watir-webdriver
311
- rubygems_version: 2.2.2
312
+ rubygems_version: 2.4.5
312
313
  signing_key:
313
314
  specification_version: 4
314
315
  summary: Watir on WebDriver