watir 6.2.1 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -7
- data/CHANGES.md +8 -0
- data/Rakefile +1 -3
- data/lib/watir/browser.rb +7 -7
- data/lib/watir/elements/element.rb +21 -5
- data/lib/watir/elements/iframe.rb +11 -2
- data/lib/watir/elements/image.rb +3 -2
- data/lib/watir/elements/select.rb +25 -4
- data/lib/watir/extensions/select_text.rb +3 -2
- data/lib/watir/locators/element/selector_builder.rb +1 -1
- data/lib/watir/locators/element/selector_builder/xpath.rb +14 -0
- data/lib/watirspec/rake_tasks.rb +2 -2
- data/spec/element_locator_spec.rb +14 -2
- data/spec/watirspec/after_hooks_spec.rb +39 -41
- data/spec/watirspec/alert_spec.rb +64 -66
- data/spec/watirspec/cookies_spec.rb +103 -105
- data/spec/watirspec/elements/div_spec.rb +1 -3
- data/spec/watirspec/elements/element_spec.rb +15 -2
- data/spec/watirspec/elements/filefield_spec.rb +33 -38
- data/spec/watirspec/elements/frame_spec.rb +5 -7
- data/spec/watirspec/elements/iframe_spec.rb +5 -7
- data/spec/watirspec/elements/select_list_spec.rb +26 -20
- data/spec/watirspec/relaxed_locate_spec.rb +8 -1
- data/spec/watirspec/window_switching_spec.rb +7 -9
- data/spec/watirspec_helper.rb +0 -4
- data/support/travis.sh +0 -26
- data/watir.gemspec +2 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d3a0cb0525118548da109542afb75980a1d42cf
|
4
|
+
data.tar.gz: 0bc02ea05b55da8b92650cecfd3a3a3fe98ab39b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03f724ca3a53ec63b963d76bc6f36f727003d52b484032ac3790f1962ad2b5a8f5e90e9864a18cd644fd51451030715a13d0d3805077749e79fce4f00d48b6cc
|
7
|
+
data.tar.gz: 66cf35ca15c505bc84dec52bc9b42303c7ba6c3473703a8edc91ea80882f1e48d6ff8d17de888ee5dcab3633dd0e7573de46d81bdafd7bba923fa851fc44a045
|
data/.travis.yml
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
dist: trusty
|
2
2
|
sudo: require
|
3
3
|
rvm:
|
4
|
-
- 2.2.
|
5
|
-
- 2.3.
|
6
|
-
- 2.4.
|
4
|
+
- 2.2.7
|
5
|
+
- 2.3.4
|
6
|
+
- 2.4.1
|
7
7
|
addons:
|
8
8
|
firefox: latest
|
9
9
|
apt:
|
@@ -20,8 +20,6 @@ notifications:
|
|
20
20
|
slack:
|
21
21
|
secure: BLsBCm33R32VNRccrLx9F0P24X6BVpVHj1OWaN4Kyn6g9qXteIwC2VKVMnKNbifpojfMkrn0OeFQFK1O1DSOsC3mgzn/udoB+DnUGcSemFUn04xhbYF5SI+3zGPKPo0JLvjjdEKSSma84YwKdrj88pGUK34p01gL8hiaqjFzWdk=
|
22
22
|
before_script:
|
23
|
-
- mkdir travis-drivers
|
24
|
-
- export PATH=$PWD/travis-drivers:$PATH
|
25
23
|
- support/travis.sh
|
26
24
|
script: bundle exec rake $RAKE_TASK
|
27
25
|
env:
|
@@ -29,6 +27,4 @@ env:
|
|
29
27
|
- RAKE_TASK=spec:firefox RELAXED_LOCATE=false
|
30
28
|
- RAKE_TASK=spec:chrome
|
31
29
|
- RAKE_TASK=spec:chrome RELAXED_LOCATE=false
|
32
|
-
- RAKE_TASK=spec:phantomjs
|
33
|
-
- RAKE_TASK=spec:phantomjs RELAXED_LOCATE=false
|
34
30
|
- RAKE_TASK=yard:doctest
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### 6.3.0 (2017-06-20)
|
2
|
+
|
3
|
+
* Allow locating elements by attribute presence/absence (#345)
|
4
|
+
* Element#flash configurable by color, number, and delay (thanks Paul3816547290)
|
5
|
+
* Implement Select#text like Select#value (thanks Arik Jones)
|
6
|
+
* Optimize Select#selected_options, Select#value, and Select#text with javascript (thanks Andrei Botalov)
|
7
|
+
* Support locating elements by #execute_script from inside frame context
|
8
|
+
|
1
9
|
### 6.2.1 (2017-03-22)
|
2
10
|
|
3
11
|
* Allow sending text to FileField without checking element is #visible?
|
data/Rakefile
CHANGED
@@ -126,7 +126,6 @@ namespace :spec do
|
|
126
126
|
task browsers: [:chrome,
|
127
127
|
:firefox,
|
128
128
|
:ff_legacy,
|
129
|
-
:phantomjs,
|
130
129
|
(:safari if Selenium::WebDriver::Platform.mac?),
|
131
130
|
(:ie if Selenium::WebDriver::Platform.windows?),
|
132
131
|
(:edge if Selenium::WebDriver::Platform.windows?)].compact
|
@@ -135,12 +134,11 @@ namespace :spec do
|
|
135
134
|
task remote_browsers: [:remote_chrome,
|
136
135
|
:remote_firefox,
|
137
136
|
:remote_ff_legacy,
|
138
|
-
:remote_phantomjs,
|
139
137
|
(:remote_safari if Selenium::WebDriver::Platform.mac?),
|
140
138
|
(:remote_ie if Selenium::WebDriver::Platform.windows?),
|
141
139
|
(:remote_edge if Selenium::WebDriver::Platform.windows?)].compact
|
142
140
|
|
143
|
-
%w(firefox ff_legacy chrome safari
|
141
|
+
%w(firefox ff_legacy chrome safari ie edge).each do |browser|
|
144
142
|
desc "Run specs in #{browser}"
|
145
143
|
task browser do
|
146
144
|
ENV['WATIR_BROWSER'] = browser
|
data/lib/watir/browser.rb
CHANGED
@@ -258,7 +258,7 @@ module Watir
|
|
258
258
|
args.map! { |e| e.kind_of?(Watir::Element) ? e.wd : e }
|
259
259
|
returned = @driver.execute_script(script, *args)
|
260
260
|
|
261
|
-
wrap_elements_in(returned)
|
261
|
+
wrap_elements_in(self, returned)
|
262
262
|
end
|
263
263
|
|
264
264
|
#
|
@@ -324,14 +324,14 @@ module Watir
|
|
324
324
|
|
325
325
|
private
|
326
326
|
|
327
|
-
def wrap_elements_in(obj)
|
327
|
+
def wrap_elements_in(scope, obj)
|
328
328
|
case obj
|
329
329
|
when Selenium::WebDriver::Element
|
330
|
-
wrap_element(obj)
|
330
|
+
wrap_element(scope, obj)
|
331
331
|
when Array
|
332
|
-
obj.map { |e| wrap_elements_in(e) }
|
332
|
+
obj.map { |e| wrap_elements_in(scope, e) }
|
333
333
|
when Hash
|
334
|
-
obj.each { |k,v| obj[k] = wrap_elements_in(v) }
|
334
|
+
obj.each { |k,v| obj[k] = wrap_elements_in(scope, v) }
|
335
335
|
|
336
336
|
obj
|
337
337
|
else
|
@@ -339,8 +339,8 @@ module Watir
|
|
339
339
|
end
|
340
340
|
end
|
341
341
|
|
342
|
-
def wrap_element(element)
|
343
|
-
Watir.element_class_for(element.tag_name.downcase).new(
|
342
|
+
def wrap_element(scope, element)
|
343
|
+
Watir.element_class_for(element.tag_name.downcase).new(scope, element: element)
|
344
344
|
end
|
345
345
|
|
346
346
|
end # Browser
|
@@ -213,19 +213,28 @@ module Watir
|
|
213
213
|
end
|
214
214
|
|
215
215
|
#
|
216
|
-
# Flashes (change background color
|
216
|
+
# Flashes (change background color to a new color and back a few times) element.
|
217
217
|
#
|
218
218
|
# @example
|
219
219
|
# browser.text_field(name: "new_user_first_name").flash
|
220
|
+
# browser.text_field(name: "new_user_first_name").flash(color: "green", flashes: 3, delay: 0.05)
|
221
|
+
# browser.text_field(name: "new_user_first_name").flash(color: "yellow")
|
222
|
+
# browser.text_field(name: "new_user_first_name").flash(flashes: 4)
|
223
|
+
# browser.text_field(name: "new_user_first_name").flash(delay: 0.1)
|
224
|
+
#
|
225
|
+
# @param [String] color what color to flash with
|
226
|
+
# @param [Integer] flashes number of times element should be flashed
|
227
|
+
# @param [Integer, Float] delay how long to wait between flashes
|
220
228
|
#
|
221
229
|
|
222
|
-
def flash
|
230
|
+
def flash(color: 'red', flashes: 10, delay: 0)
|
223
231
|
background_color = style("backgroundColor")
|
224
232
|
element_color = driver.execute_script("arguments[0].style.backgroundColor", @element)
|
225
233
|
|
226
|
-
|
227
|
-
|
228
|
-
driver.execute_script("arguments[0].style.backgroundColor = '#{
|
234
|
+
flashes.times do |n|
|
235
|
+
nextcolor = n.even? ? color : background_color
|
236
|
+
driver.execute_script("arguments[0].style.backgroundColor = '#{nextcolor}'", @element)
|
237
|
+
sleep(delay)
|
229
238
|
end
|
230
239
|
|
231
240
|
driver.execute_script("arguments[0].style.backgroundColor = arguments[1]", @element, element_color)
|
@@ -458,6 +467,13 @@ module Watir
|
|
458
467
|
@query_scope.browser
|
459
468
|
end
|
460
469
|
|
470
|
+
#
|
471
|
+
# Delegates script execution to Browser or IFrame.
|
472
|
+
#
|
473
|
+
def execute_script(script, *args)
|
474
|
+
@query_scope.execute_script(script, *args)
|
475
|
+
end
|
476
|
+
|
461
477
|
#
|
462
478
|
# Returns true if a previously located element is no longer attached to DOM.
|
463
479
|
#
|
@@ -54,8 +54,17 @@ module Watir
|
|
54
54
|
wd.page_source
|
55
55
|
end
|
56
56
|
|
57
|
-
|
58
|
-
|
57
|
+
#
|
58
|
+
# Executes JavaScript snippet in context of frame.
|
59
|
+
#
|
60
|
+
# @see Watir::Browser#execute_script
|
61
|
+
#
|
62
|
+
|
63
|
+
def execute_script(script, *args)
|
64
|
+
args.map! { |e| e.kind_of?(Watir::Element) ? e.wd : e }
|
65
|
+
returned = driver.execute_script(script, *args)
|
66
|
+
|
67
|
+
browser.send :wrap_elements_in, self, returned
|
59
68
|
end
|
60
69
|
|
61
70
|
private
|
data/lib/watir/elements/image.rb
CHANGED
@@ -100,19 +100,40 @@ module Watir
|
|
100
100
|
#
|
101
101
|
|
102
102
|
def value
|
103
|
-
|
104
|
-
|
103
|
+
option = selected_options.first
|
104
|
+
option && option.value
|
105
105
|
end
|
106
106
|
|
107
|
-
|
108
107
|
#
|
108
|
+
# Returns the text of the first selected option in the select list.
|
109
|
+
# Returns nil if no option is selected.
|
110
|
+
#
|
111
|
+
# @return [String, nil]
|
112
|
+
#
|
113
|
+
|
114
|
+
def text
|
115
|
+
option = selected_options.first
|
116
|
+
option && option.text
|
117
|
+
end
|
118
|
+
|
109
119
|
# Returns an array of currently selected options.
|
110
120
|
#
|
111
121
|
# @return [Array<Watir::Option>]
|
112
122
|
#
|
113
123
|
|
114
124
|
def selected_options
|
115
|
-
|
125
|
+
element_call do
|
126
|
+
script = <<-SCRIPT
|
127
|
+
var result = [];
|
128
|
+
var options = arguments[0].options;
|
129
|
+
for (var i = 0; i < options.length; i++) {
|
130
|
+
var option = options[i];
|
131
|
+
if (option.selected) { result.push(option) }
|
132
|
+
}
|
133
|
+
return result;
|
134
|
+
SCRIPT
|
135
|
+
@query_scope.execute_script(script, self)
|
136
|
+
end
|
116
137
|
end
|
117
138
|
|
118
139
|
private
|
@@ -2,7 +2,7 @@ module Watir
|
|
2
2
|
module Locators
|
3
3
|
class Element
|
4
4
|
class SelectorBuilder
|
5
|
-
VALID_WHATS = [String, Regexp]
|
5
|
+
VALID_WHATS = [String, Regexp, TrueClass, FalseClass].freeze
|
6
6
|
WILDCARD_ATTRIBUTE = /^(aria|data)_(.+)$/
|
7
7
|
|
8
8
|
def initialize(query_scope, selector, valid_attributes)
|
@@ -28,6 +28,10 @@ module Watir
|
|
28
28
|
f = selectors.map do |key, val|
|
29
29
|
if val.is_a?(Array)
|
30
30
|
"(" + val.map { |v| equal_pair(building, key, v) }.join(" or ") + ")"
|
31
|
+
elsif val == true
|
32
|
+
attribute_presence(key)
|
33
|
+
elsif val == false
|
34
|
+
attribute_absence(key)
|
31
35
|
else
|
32
36
|
equal_pair(building, key, val)
|
33
37
|
end
|
@@ -65,6 +69,16 @@ module Watir
|
|
65
69
|
"@#{key.to_s.tr("_", "-")}"
|
66
70
|
end
|
67
71
|
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def attribute_presence(attribute)
|
76
|
+
lhs_for(nil, attribute)
|
77
|
+
end
|
78
|
+
|
79
|
+
def attribute_absence(attribute)
|
80
|
+
"not(#{lhs_for(nil, attribute)})"
|
81
|
+
end
|
68
82
|
end
|
69
83
|
end
|
70
84
|
end
|
data/lib/watirspec/rake_tasks.rb
CHANGED
@@ -83,9 +83,9 @@ WatirSpec.implementation do |watirspec|
|
|
83
83
|
#
|
84
84
|
# watirspec.name = :watizzle
|
85
85
|
# watirspec.browser_class = Watir::Browser
|
86
|
-
# watirspec.browser_args = [:
|
86
|
+
# watirspec.browser_args = [:firefox, {}]
|
87
87
|
# watirspec.guard_proc = lambda do |args|
|
88
|
-
# args.include?(:
|
88
|
+
# args.include?(:firefox)
|
89
89
|
# end
|
90
90
|
end
|
91
91
|
|
@@ -47,6 +47,18 @@ describe Watir::Locators::Element::Locator do
|
|
47
47
|
locate_one [:dir, "foo",
|
48
48
|
:title, "bar"]
|
49
49
|
end
|
50
|
+
|
51
|
+
it "handles selector with attribute presence" do
|
52
|
+
expect_one :xpath, ".//*[@data-view]"
|
53
|
+
|
54
|
+
locate_one [:data_view, true]
|
55
|
+
end
|
56
|
+
|
57
|
+
it "handles selector with attribute absence" do
|
58
|
+
expect_one :xpath, ".//*[not(@data-view)]"
|
59
|
+
|
60
|
+
locate_one [:data_view, false]
|
61
|
+
end
|
50
62
|
end
|
51
63
|
|
52
64
|
describe "with special cased selectors" do
|
@@ -288,10 +300,10 @@ describe Watir::Locators::Element::Locator do
|
|
288
300
|
raise_error(TypeError, %[expected Integer, got "bar":String])
|
289
301
|
end
|
290
302
|
|
291
|
-
it "raises a TypeError if selector value is not a String or
|
303
|
+
it "raises a TypeError if selector value is not a String, Regexp or Boolean" do
|
292
304
|
num_type = RUBY_VERSION[/^\d+\.(\d+)/, 1].to_i >= 4 ? 'Integer' : 'Fixnum'
|
293
305
|
expect { locate_one(tag_name: 123) }.to \
|
294
|
-
raise_error(TypeError, %[expected one of [String, Regexp], got 123:#{num_type}])
|
306
|
+
raise_error(TypeError, %[expected one of [String, Regexp, TrueClass, FalseClass], got 123:#{num_type}])
|
295
307
|
end
|
296
308
|
|
297
309
|
it "raises a MissingWayOfFindingObjectException if the attribute is not valid" do
|
@@ -104,61 +104,59 @@ describe "Browser::AfterHooks" do
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
|
108
|
-
|
109
|
-
|
107
|
+
not_compliant_on :safari do
|
108
|
+
it "runs after_hooks after Alert#ok" do
|
109
|
+
browser.goto(WatirSpec.url_for("alerts.html"))
|
110
|
+
@page_after_hook = Proc.new { @yield = browser.title == "Alerts" }
|
111
|
+
browser.after_hooks.add @page_after_hook
|
112
|
+
browser.after_hooks.without { browser.button(id: 'alert').click }
|
113
|
+
browser.alert.ok
|
114
|
+
expect(@yield).to be true
|
115
|
+
end
|
116
|
+
|
117
|
+
bug "https://code.google.com/p/chromedriver/issues/detail?id=26", [:chrome, :macosx] do
|
118
|
+
it "runs after_hooks after Alert#close" do
|
110
119
|
browser.goto(WatirSpec.url_for("alerts.html"))
|
111
120
|
@page_after_hook = Proc.new { @yield = browser.title == "Alerts" }
|
112
121
|
browser.after_hooks.add @page_after_hook
|
113
122
|
browser.after_hooks.without { browser.button(id: 'alert').click }
|
114
|
-
browser.alert.
|
123
|
+
browser.alert.close
|
115
124
|
expect(@yield).to be true
|
116
125
|
end
|
126
|
+
end
|
117
127
|
|
118
|
-
|
119
|
-
|
120
|
-
browser.goto(WatirSpec.url_for("alerts.html"))
|
121
|
-
@page_after_hook = Proc.new { @yield = browser.title == "Alerts" }
|
122
|
-
browser.after_hooks.add @page_after_hook
|
123
|
-
browser.after_hooks.without { browser.button(id: 'alert').click }
|
124
|
-
browser.alert.close
|
125
|
-
expect(@yield).to be true
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1279211", :firefox do
|
130
|
-
it "raises UnhandledAlertError error when running error checks with alert present" do
|
131
|
-
url = WatirSpec.url_for("alerts.html")
|
132
|
-
@page_after_hook = Proc.new { browser.url }
|
133
|
-
browser.after_hooks.add @page_after_hook
|
134
|
-
browser.goto url
|
135
|
-
expect { browser.button(id: "alert").click }.to raise_error(Selenium::WebDriver::Error::UnhandledAlertError)
|
136
|
-
|
137
|
-
not_compliant_on :ff_legacy do
|
138
|
-
browser.alert.ok
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
it "does not raise error when running error checks using #after_hooks#without with alert present" do
|
128
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1279211", :firefox do
|
129
|
+
it "raises UnhandledAlertError error when running error checks with alert present" do
|
144
130
|
url = WatirSpec.url_for("alerts.html")
|
145
131
|
@page_after_hook = Proc.new { browser.url }
|
146
132
|
browser.after_hooks.add @page_after_hook
|
147
133
|
browser.goto url
|
148
|
-
expect { browser.
|
149
|
-
browser.alert.ok
|
150
|
-
end
|
134
|
+
expect { browser.button(id: "alert").click }.to raise_error(Selenium::WebDriver::Error::UnhandledAlertError)
|
151
135
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
browser.after_hooks.add @page_after_hook
|
156
|
-
browser.goto url
|
157
|
-
browser.after_hooks.delete @page_after_hook
|
158
|
-
expect { browser.button(id: "alert").click }.to_not raise_error
|
159
|
-
browser.alert.ok
|
136
|
+
not_compliant_on :ff_legacy do
|
137
|
+
browser.alert.ok
|
138
|
+
end
|
160
139
|
end
|
161
140
|
end
|
141
|
+
|
142
|
+
it "does not raise error when running error checks using #after_hooks#without with alert present" do
|
143
|
+
url = WatirSpec.url_for("alerts.html")
|
144
|
+
@page_after_hook = Proc.new { browser.url }
|
145
|
+
browser.after_hooks.add @page_after_hook
|
146
|
+
browser.goto url
|
147
|
+
expect { browser.after_hooks.without { browser.button(id: "alert").click } }.to_not raise_error
|
148
|
+
browser.alert.ok
|
149
|
+
end
|
150
|
+
|
151
|
+
it "does not raise error if no error checks are defined with alert present" do
|
152
|
+
url = WatirSpec.url_for("alerts.html")
|
153
|
+
@page_after_hook = Proc.new { browser.url }
|
154
|
+
browser.after_hooks.add @page_after_hook
|
155
|
+
browser.goto url
|
156
|
+
browser.after_hooks.delete @page_after_hook
|
157
|
+
expect { browser.button(id: "alert").click }.to_not raise_error
|
158
|
+
browser.alert.ok
|
159
|
+
end
|
162
160
|
end
|
163
161
|
|
164
162
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1223277", :firefox do
|
@@ -1,98 +1,96 @@
|
|
1
1
|
require "watirspec_helper"
|
2
2
|
|
3
3
|
describe 'Alert API' do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
not_compliant_on :safari do
|
5
|
+
before do
|
6
|
+
browser.goto WatirSpec.url_for("alerts.html")
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
browser.alert.ok if browser.alert.exists?
|
11
|
+
end
|
9
12
|
|
10
|
-
|
11
|
-
|
13
|
+
context 'alert' do
|
14
|
+
describe '#text' do
|
15
|
+
it 'returns text of alert' do
|
16
|
+
browser.button(id: 'alert').click
|
17
|
+
expect(browser.alert.text).to include('ok')
|
18
|
+
end
|
12
19
|
end
|
13
20
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
browser.button(id: 'alert').click
|
18
|
-
expect(browser.alert.text).to include('ok')
|
19
|
-
end
|
21
|
+
describe '#exists?' do
|
22
|
+
it 'returns false if alert is not present' do
|
23
|
+
expect(browser.alert).to_not exist
|
20
24
|
end
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
it 'returns true if alert is present' do
|
27
|
+
browser.button(id: 'alert').click
|
28
|
+
browser.wait_until(timeout: 10) { browser.alert.exists? }
|
29
|
+
end
|
30
|
+
end
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
describe '#ok' do
|
33
|
+
it 'closes alert' do
|
34
|
+
browser.button(id: 'alert').click
|
35
|
+
browser.alert.ok
|
36
|
+
expect(browser.alert).to_not exist
|
31
37
|
end
|
38
|
+
end
|
32
39
|
|
33
|
-
|
40
|
+
bug "https://code.google.com/p/chromedriver/issues/detail?id=26", [:chrome, :macosx] do
|
41
|
+
describe '#close' do
|
34
42
|
it 'closes alert' do
|
35
43
|
browser.button(id: 'alert').click
|
36
|
-
browser.alert.
|
44
|
+
browser.alert.close
|
37
45
|
expect(browser.alert).to_not exist
|
38
46
|
end
|
39
47
|
end
|
48
|
+
end
|
40
49
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
50
|
+
not_compliant_on :relaxed_locate do
|
51
|
+
describe 'wait_until_present' do
|
52
|
+
it 'waits until alert is present and goes on' do
|
53
|
+
browser.button(id: 'timeout-alert').click
|
54
|
+
browser.alert.wait_until_present.ok
|
55
|
+
|
56
|
+
expect(browser.alert).to_not exist
|
48
57
|
end
|
49
|
-
end
|
50
58
|
|
51
|
-
|
52
|
-
|
53
|
-
it 'waits until alert is present and goes on' do
|
54
|
-
browser.button(id: 'timeout-alert').click
|
59
|
+
it 'raises error if alert is not present after timeout' do
|
60
|
+
expect {
|
55
61
|
browser.alert.wait_until_present.ok
|
56
|
-
|
57
|
-
expect(browser.alert).to_not exist
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'raises error if alert is not present after timeout' do
|
61
|
-
expect {
|
62
|
-
browser.alert.wait_until_present.ok
|
63
|
-
}.to raise_error(Watir::Wait::TimeoutError)
|
64
|
-
end
|
62
|
+
}.to raise_error(Watir::Wait::TimeoutError)
|
65
63
|
end
|
66
64
|
end
|
67
65
|
end
|
66
|
+
end
|
68
67
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
68
|
+
context 'confirm' do
|
69
|
+
describe '#ok' do
|
70
|
+
it 'accepts confirm' do
|
71
|
+
browser.button(id: 'confirm').click
|
72
|
+
browser.alert.ok
|
73
|
+
expect(browser.button(id: 'confirm').value).to eq "true"
|
76
74
|
end
|
75
|
+
end
|
77
76
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
77
|
+
describe '#close' do
|
78
|
+
it 'cancels confirm' do
|
79
|
+
browser.button(id: 'confirm').click
|
80
|
+
browser.alert.close
|
81
|
+
expect(browser.button(id: 'confirm').value).to eq "false"
|
84
82
|
end
|
85
83
|
end
|
84
|
+
end
|
86
85
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
86
|
+
context 'prompt' do
|
87
|
+
describe '#set' do
|
88
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1255906", :firefox do
|
89
|
+
it 'enters text to prompt' do
|
90
|
+
browser.button(id: 'prompt').click
|
91
|
+
browser.alert.set 'My Name'
|
92
|
+
browser.alert.ok
|
93
|
+
expect(browser.button(id: 'prompt').value).to eq 'My Name'
|
96
94
|
end
|
97
95
|
end
|
98
96
|
end
|