watir 6.6.0 → 6.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/watir/capabilities.rb +4 -2
- data/lib/watirspec/guards.rb +1 -1
- data/spec/browser_spec.rb +19 -7
- data/spec/element_spec.rb +9 -11
- data/spec/watirspec/after_hooks_spec.rb +8 -10
- data/spec/watirspec/alert_spec.rb +5 -7
- data/spec/watirspec/browser_spec.rb +13 -17
- data/spec/watirspec/cookies_spec.rb +11 -13
- data/spec/watirspec/drag_and_drop_spec.rb +3 -3
- data/spec/watirspec/elements/div_spec.rb +2 -2
- data/spec/watirspec/elements/element_spec.rb +47 -53
- data/spec/watirspec/elements/filefield_spec.rb +35 -39
- data/spec/watirspec/elements/form_spec.rb +13 -15
- data/spec/watirspec/elements/iframe_spec.rb +11 -15
- data/spec/watirspec/elements/image_spec.rb +16 -18
- data/spec/watirspec/elements/select_list_spec.rb +74 -92
- data/spec/watirspec/elements/text_field_spec.rb +5 -9
- data/spec/watirspec/elements/tr_spec.rb +3 -5
- data/spec/watirspec/window_switching_spec.rb +37 -43
- data/support/doctest_helper.rb +1 -0
- data/watir.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10cab1d1409ebe3bb8f7e249a6d3ee1a8b2523b1
|
4
|
+
data.tar.gz: a0c781ce798236ee4b2d9c87a37825c05b6f55d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d292a95a5839ccd31ae7f1696351af2e0e515faf2abcaa9cff723234b42cc9fa237b520be2ac152b09b70e31e2953f3ab61c5bee90cbccfaa1e94ced83f724d6
|
7
|
+
data.tar.gz: 46a0338d87dc84aab77d24931664a4fe9578826f9211c0a898abe1bf2ff4ebfaa9a3f52478b55acaa5b80095e4788874703c7e4612185a542cd38192f615fa17
|
data/CHANGES.md
CHANGED
data/lib/watir/capabilities.rb
CHANGED
@@ -65,9 +65,11 @@ module Watir
|
|
65
65
|
browser_options[:args] << '--headless'
|
66
66
|
browser_options[:args] << '--disable-gpu'
|
67
67
|
end
|
68
|
-
@selenium_opts[:options] = Selenium::WebDriver::Chrome::Options
|
68
|
+
@selenium_opts[:options] = browser_options if browser_options.is_a? Selenium::WebDriver::Chrome::Options
|
69
|
+
@selenium_opts[:options] ||= Selenium::WebDriver::Chrome::Options.new(browser_options) if browser_options
|
69
70
|
when :firefox
|
70
|
-
@selenium_opts[:options] = Selenium::WebDriver::Firefox::Options
|
71
|
+
@selenium_opts[:options] = browser_options if browser_options.is_a? Selenium::WebDriver::Firefox::Options
|
72
|
+
@selenium_opts[:options] ||= Selenium::WebDriver::Firefox::Options.new(options) if browser_options
|
71
73
|
when :safari
|
72
74
|
@selenium_opts["safari.options"] = {'technologyPreview' => true} if @options[:technology_preview]
|
73
75
|
when :remote
|
data/lib/watirspec/guards.rb
CHANGED
@@ -20,7 +20,7 @@ module WatirSpec
|
|
20
20
|
gs.each do |guard|
|
21
21
|
guard[:data][:file] = guard[:data][:file][/\/spec\/(.*):/, 1]
|
22
22
|
guard_name = "#{guard[:name]}:".ljust(15)
|
23
|
-
str << " \t#{guard_name} #{guard[:data].inspect}"
|
23
|
+
str << " \t#{guard_name} #{guard[:data].inspect}\n"
|
24
24
|
end
|
25
25
|
Watir.logger.warn str
|
26
26
|
end
|
data/spec/browser_spec.rb
CHANGED
@@ -88,6 +88,20 @@ describe Watir::Browser do
|
|
88
88
|
expect(ua).to eq('foo;bar')
|
89
89
|
new_browser.close
|
90
90
|
end
|
91
|
+
|
92
|
+
not_compliant_on :headless do
|
93
|
+
it "accepts Chrome::Options instance as :options" do
|
94
|
+
chrome_opts = Selenium::WebDriver::Chrome::Options.new(emulation: {userAgent: 'foo;bar'})
|
95
|
+
@opts.delete :args
|
96
|
+
@opts.merge!(options: chrome_opts)
|
97
|
+
|
98
|
+
new_browser = WatirSpec.new_browser
|
99
|
+
|
100
|
+
ua = new_browser.execute_script 'return window.navigator.userAgent'
|
101
|
+
expect(ua).to eq('foo;bar')
|
102
|
+
new_browser.close
|
103
|
+
end
|
104
|
+
end
|
91
105
|
end
|
92
106
|
end
|
93
107
|
|
@@ -149,14 +163,12 @@ describe Watir::Browser do
|
|
149
163
|
end
|
150
164
|
end
|
151
165
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
browser.close
|
166
|
+
it "raises an error when trying to interact with a closed browser" do
|
167
|
+
browser.goto WatirSpec.url_for "definition_lists.html"
|
168
|
+
browser.close
|
156
169
|
|
157
|
-
|
158
|
-
|
159
|
-
end
|
170
|
+
expect { browser.dl(id: "experience-list").id }.to raise_error(Watir::Exception::Error, "browser was closed")
|
171
|
+
$browser = WatirSpec.new_browser
|
160
172
|
end
|
161
173
|
|
162
174
|
describe "#wait_while" do
|
data/spec/element_spec.rb
CHANGED
@@ -91,17 +91,15 @@ describe Watir::Element do
|
|
91
91
|
|
92
92
|
end
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
expect(link.style("font-size")).to eq "20px"
|
104
|
-
end
|
94
|
+
describe "#hover" do
|
95
|
+
not_compliant_on :internet_explorer, :safari, %i(remote firefox) do
|
96
|
+
it "should hover over the element" do
|
97
|
+
browser.goto WatirSpec.url_for('hover.html')
|
98
|
+
link = browser.a
|
99
|
+
|
100
|
+
expect(link.style("font-size")).to eq "10px"
|
101
|
+
link.hover
|
102
|
+
expect(link.style("font-size")).to eq "20px"
|
105
103
|
end
|
106
104
|
end
|
107
105
|
end
|
@@ -70,15 +70,13 @@ describe "Browser::AfterHooks" do
|
|
70
70
|
expect(@yield).to be true
|
71
71
|
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
expect(@yield).to be true
|
81
|
-
end
|
73
|
+
not_compliant_on :safari do
|
74
|
+
it "runs after_hooks after Element#submit" do
|
75
|
+
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
|
76
|
+
@page_after_hook = Proc.new { @yield = browser.div(id: 'messages').text == 'submit' }
|
77
|
+
browser.after_hooks.add @page_after_hook
|
78
|
+
browser.form(id: "new_user").submit
|
79
|
+
expect(@yield).to be true
|
82
80
|
end
|
83
81
|
end
|
84
82
|
|
@@ -92,7 +90,7 @@ describe "Browser::AfterHooks" do
|
|
92
90
|
end
|
93
91
|
end
|
94
92
|
|
95
|
-
|
93
|
+
not_compliant_on %i(remote firefox) do
|
96
94
|
it "runs after_hooks after Element#right_click" do
|
97
95
|
browser.goto(WatirSpec.url_for("right_click.html"))
|
98
96
|
@page_after_hook = Proc.new { @yield = browser.title == "Right Click Test" }
|
@@ -96,13 +96,11 @@ not_compliant_on :headless do
|
|
96
96
|
|
97
97
|
context 'prompt' do
|
98
98
|
describe '#set' do
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
expect(browser.button(id: 'prompt').value).to eq 'My Name'
|
105
|
-
end
|
99
|
+
it 'enters text to prompt' do
|
100
|
+
browser.button(id: 'prompt').click
|
101
|
+
browser.alert.set 'My Name'
|
102
|
+
browser.alert.ok
|
103
|
+
expect(browser.button(id: 'prompt').value).to eq 'My Name'
|
106
104
|
end
|
107
105
|
end
|
108
106
|
end
|
@@ -27,12 +27,10 @@ describe "Browser" do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
$browser = WatirSpec.new_browser
|
35
|
-
end
|
30
|
+
it "returns false after Browser#close" do
|
31
|
+
browser.close
|
32
|
+
expect(browser).to_not exist
|
33
|
+
$browser = WatirSpec.new_browser
|
36
34
|
end
|
37
35
|
end
|
38
36
|
|
@@ -134,17 +132,15 @@ describe "Browser" do
|
|
134
132
|
end
|
135
133
|
|
136
134
|
describe ".start" do
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
$browser = WatirSpec.new_browser
|
147
|
-
end
|
135
|
+
it "goes to the given URL and return an instance of itself" do
|
136
|
+
browser.close
|
137
|
+
driver, args = WatirSpec.implementation.browser_args
|
138
|
+
b = Watir::Browser.start(WatirSpec.url_for("non_control_elements.html"), driver, args.dup)
|
139
|
+
|
140
|
+
expect(b).to be_instance_of(Watir::Browser)
|
141
|
+
expect(b.title).to eq "Non-control elements"
|
142
|
+
b.close
|
143
|
+
$browser = WatirSpec.new_browser
|
148
144
|
end
|
149
145
|
end
|
150
146
|
|
@@ -113,19 +113,17 @@ describe "Browser#cookies" do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
describe '#load' do
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
expect(actual).to eq(expected)
|
128
|
-
end
|
116
|
+
it 'loads cookies from file' do
|
117
|
+
browser.cookies.clear
|
118
|
+
browser.cookies.load file
|
119
|
+
expected = browser.cookies.to_a
|
120
|
+
actual = YAML.load(IO.read(file))
|
121
|
+
|
122
|
+
# https://code.google.com/p/selenium/issues/detail?id=6834
|
123
|
+
expected.each { |cookie| cookie.delete(:expires) }
|
124
|
+
actual.each { |cookie| cookie.delete(:expires) }
|
125
|
+
|
126
|
+
expect(actual).to eq(expected)
|
129
127
|
end
|
130
128
|
end
|
131
129
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "watirspec_helper"
|
2
2
|
|
3
3
|
describe "Element" do
|
4
|
-
|
4
|
+
not_compliant_on %i(remote firefox) do
|
5
5
|
bug "Safari does not strip text", :safari do
|
6
6
|
context "drag and drop" do
|
7
7
|
before { browser.goto WatirSpec.url_for("drag_and_drop.html") }
|
@@ -15,7 +15,7 @@ describe "Element" do
|
|
15
15
|
expect(droppable.text).to eq 'Dropped!'
|
16
16
|
end
|
17
17
|
|
18
|
-
not_compliant_on :headless do
|
18
|
+
not_compliant_on :headless, :firefox do
|
19
19
|
it "can drag and drop an element onto another when draggable is out of viewport" do
|
20
20
|
reposition "draggable"
|
21
21
|
perform_drag_and_drop_on_droppable
|
@@ -43,7 +43,7 @@ describe "Element" do
|
|
43
43
|
expect(droppable.text).to eq 'Dropped!'
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
47
46
|
end
|
47
|
+
|
48
48
|
end
|
49
49
|
end
|
@@ -156,7 +156,7 @@ describe "Div" do
|
|
156
156
|
end
|
157
157
|
|
158
158
|
not_compliant_on :safari do
|
159
|
-
bug "
|
159
|
+
bug "MoveTargetOutOfBoundsError", :firefox do
|
160
160
|
describe "#double_click" do
|
161
161
|
it "fires the ondblclick event" do
|
162
162
|
browser.div(id: 'html_test').double_click
|
@@ -165,7 +165,7 @@ describe "Div" do
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
-
|
168
|
+
not_compliant_on :firefox do
|
169
169
|
describe "#right_click" do
|
170
170
|
it "fires the oncontextmenu event" do
|
171
171
|
browser.goto(WatirSpec.url_for("right_click.html"))
|
@@ -151,13 +151,11 @@ describe "Element" do
|
|
151
151
|
end
|
152
152
|
|
153
153
|
describe "#focus" do
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
expect(browser.div(id: "onfocus_test").text).to eq "changed by onfocus event"
|
160
|
-
end
|
154
|
+
it "fires the onfocus event for the given element" do
|
155
|
+
tf = browser.text_field(id: "new_user_occupation")
|
156
|
+
expect(tf.value).to eq "Developer"
|
157
|
+
tf.focus
|
158
|
+
expect(browser.div(id: "onfocus_test").text).to eq "changed by onfocus event"
|
161
159
|
end
|
162
160
|
end
|
163
161
|
|
@@ -173,12 +171,10 @@ describe "Element" do
|
|
173
171
|
end
|
174
172
|
|
175
173
|
describe "#fire_event" do
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
expect(browser.div(id: "onfocus_test").text).to eq "changed by onfocus event"
|
181
|
-
end
|
174
|
+
it "should fire the given event" do
|
175
|
+
expect(browser.div(id: "onfocus_test").text).to be_empty
|
176
|
+
browser.text_field(id: "new_user_occupation").fire_event('onfocus')
|
177
|
+
expect(browser.div(id: "onfocus_test").text).to eq "changed by onfocus event"
|
182
178
|
end
|
183
179
|
end
|
184
180
|
|
@@ -314,50 +310,48 @@ describe "Element" do
|
|
314
310
|
end
|
315
311
|
end
|
316
312
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
end
|
313
|
+
describe '#send_keys' do
|
314
|
+
before(:each) do
|
315
|
+
@c = Selenium::WebDriver::Platform.mac? ? :command : :control
|
316
|
+
browser.goto(WatirSpec.url_for('keylogger.html'))
|
317
|
+
end
|
323
318
|
|
324
|
-
|
325
|
-
|
319
|
+
let(:receiver) { browser.text_field(id: 'receiver') }
|
320
|
+
let(:events) { browser.element(id: 'output').ps.size }
|
326
321
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
322
|
+
it 'sends keystrokes to the element' do
|
323
|
+
receiver.send_keys 'hello world'
|
324
|
+
expect(receiver.value).to eq 'hello world'
|
325
|
+
expect(events).to eq 11
|
326
|
+
end
|
332
327
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
328
|
+
it 'accepts arbitrary list of arguments' do
|
329
|
+
receiver.send_keys 'hello', 'world'
|
330
|
+
expect(receiver.value).to eq 'helloworld'
|
331
|
+
expect(events).to eq 10
|
332
|
+
end
|
333
|
+
|
334
|
+
bug "http://code.google.com/p/chromium/issues/detail?id=93879", :chrome do
|
335
|
+
not_compliant_on :safari, :firefox do
|
336
|
+
it 'performs key combinations' do
|
337
|
+
receiver.send_keys 'foo'
|
338
|
+
receiver.send_keys [@c, 'a']
|
339
|
+
receiver.send_keys :backspace
|
340
|
+
expect(receiver.value).to be_empty
|
341
|
+
expect(events).to eq 6
|
342
|
+
end
|
343
|
+
|
344
|
+
it 'performs arbitrary list of key combinations' do
|
345
|
+
receiver.send_keys 'foo'
|
346
|
+
receiver.send_keys [@c, 'a'], [@c, 'x']
|
347
|
+
expect(receiver.value).to be_empty
|
348
|
+
expect(events).to eq 7
|
349
|
+
end
|
338
350
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
receiver.send_keys [@c, 'a']
|
344
|
-
receiver.send_keys :backspace
|
345
|
-
expect(receiver.value).to be_empty
|
346
|
-
expect(events).to eq 6
|
347
|
-
end
|
348
|
-
|
349
|
-
it 'performs arbitrary list of key combinations' do
|
350
|
-
receiver.send_keys 'foo'
|
351
|
-
receiver.send_keys [@c, 'a'], [@c, 'x']
|
352
|
-
expect(receiver.value).to be_empty
|
353
|
-
expect(events).to eq 7
|
354
|
-
end
|
355
|
-
|
356
|
-
it 'supports combination of strings and arrays' do
|
357
|
-
receiver.send_keys 'foo', [@c, 'a'], :backspace
|
358
|
-
expect(receiver.value).to be_empty
|
359
|
-
expect(events).to eq 6
|
360
|
-
end
|
351
|
+
it 'supports combination of strings and arrays' do
|
352
|
+
receiver.send_keys 'foo', [@c, 'a'], :backspace
|
353
|
+
expect(receiver.value).to be_empty
|
354
|
+
expect(events).to eq 6
|
361
355
|
end
|
362
356
|
end
|
363
357
|
end
|
@@ -109,63 +109,59 @@ describe "FileField" do
|
|
109
109
|
|
110
110
|
describe "#set" do
|
111
111
|
not_compliant_on :safari do
|
112
|
-
|
113
|
-
|
114
|
-
browser.goto WatirSpec.url_for("forms_with_input_elements.html")
|
112
|
+
it "is able to set a file path in the field and click the upload button and fire the onchange event" do
|
113
|
+
browser.goto WatirSpec.url_for("forms_with_input_elements.html")
|
115
114
|
|
116
|
-
|
117
|
-
|
115
|
+
path = File.expand_path(__FILE__)
|
116
|
+
element = browser.file_field(name: "new_user_portrait")
|
118
117
|
|
119
|
-
|
118
|
+
element.set path
|
120
119
|
|
121
|
-
|
122
|
-
|
120
|
+
expect(element.value).to include(File.basename(path)) # only some browser will return the full path
|
121
|
+
expect(messages.first).to include(File.basename(path))
|
123
122
|
|
124
|
-
|
125
|
-
|
123
|
+
browser.button(name: "new_user_submit").click
|
124
|
+
end
|
126
125
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
126
|
+
it "raises an error if the file does not exist" do
|
127
|
+
expect {
|
128
|
+
browser.file_field.set(File.join(Dir.tmpdir, 'unlikely-to-exist'))
|
129
|
+
}.to raise_error(Errno::ENOENT)
|
132
130
|
end
|
133
131
|
end
|
134
132
|
end
|
135
133
|
|
136
134
|
not_compliant_on :safari do
|
137
135
|
describe "#value=" do
|
138
|
-
|
139
|
-
|
140
|
-
browser.goto WatirSpec.url_for("forms_with_input_elements.html")
|
136
|
+
it "is able to set a file path in the field and click the upload button and fire the onchange event" do
|
137
|
+
browser.goto WatirSpec.url_for("forms_with_input_elements.html")
|
141
138
|
|
142
|
-
|
143
|
-
|
139
|
+
path = File.expand_path(__FILE__)
|
140
|
+
element = browser.file_field(name: "new_user_portrait")
|
144
141
|
|
145
|
-
|
146
|
-
|
147
|
-
|
142
|
+
element.value = path
|
143
|
+
expect(element.value).to include(File.basename(path)) # only some browser will return the full path
|
144
|
+
end
|
148
145
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
146
|
+
not_compliant_on :internet_explorer do
|
147
|
+
bug "Raises File not found error - File Bug Report", :firefox do
|
148
|
+
it "does not raise an error if the file does not exist" do
|
149
|
+
path = File.join(Dir.tmpdir, 'unlikely-to-exist')
|
150
|
+
browser.file_field.value = path
|
154
151
|
|
155
|
-
|
156
|
-
|
152
|
+
expected = path
|
153
|
+
expected.gsub!("/", "\\") if Selenium::WebDriver::Platform.windows?
|
157
154
|
|
158
|
-
|
159
|
-
end
|
155
|
+
expect(browser.file_field.value).to include(File.basename(expected)) # only some browser will return the full path
|
160
156
|
end
|
157
|
+
end
|
161
158
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
end
|
159
|
+
not_compliant_on %i(chrome windows) do
|
160
|
+
bug "Raises File not found error - File Bug Report", :firefox do
|
161
|
+
it "does not alter its argument" do
|
162
|
+
value = '/foo/bar'
|
163
|
+
browser.file_field.value = value
|
164
|
+
expect(value).to eq '/foo/bar'
|
169
165
|
end
|
170
166
|
end
|
171
167
|
end
|
@@ -49,22 +49,20 @@ describe "Form" do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
52
|
+
describe "#submit" do
|
53
|
+
it "submits the form" do
|
54
|
+
browser.form(id: "delete_user").submit
|
55
|
+
Watir::Wait.until { !browser.url.include? 'forms_with_input_elements.html' }
|
56
|
+
expect(browser.text).to include("Semantic table")
|
57
|
+
end
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
59
|
+
not_compliant_on :safari do
|
60
|
+
it "triggers onsubmit event and takes its result into account" do
|
61
|
+
form = browser.form(name: "user_new")
|
62
|
+
form.submit
|
63
|
+
expect(form).to exist
|
64
|
+
expect(messages.size).to eq 1
|
65
|
+
expect(messages[0]).to eq "submit"
|
68
66
|
end
|
69
67
|
end
|
70
68
|
end
|
@@ -10,16 +10,14 @@ describe "IFrame" do
|
|
10
10
|
browser.goto(WatirSpec.url_for("iframes.html"))
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
expect(browser.iframe(id: "iframe_2").text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
22
|
-
end
|
13
|
+
not_compliant_on :safari do
|
14
|
+
it "handles crossframe javascript" do
|
15
|
+
browser.goto WatirSpec.url_for("iframes.html")
|
16
|
+
|
17
|
+
expect(browser.iframe(id: "iframe_1").text_field(name: 'senderElement').value).to eq 'send_this_value'
|
18
|
+
expect(browser.iframe(id: "iframe_2").text_field(name: 'recieverElement').value).to eq 'old_value'
|
19
|
+
browser.iframe(id: "iframe_1").button(id: 'send').click
|
20
|
+
expect(browser.iframe(id: "iframe_2").text_field(name: 'recieverElement').value).to eq 'send_this_value'
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
@@ -148,11 +146,9 @@ describe "IFrame" do
|
|
148
146
|
expect { browser.iframe(index: 0).foo }.to raise_error(NoMethodError)
|
149
147
|
end
|
150
148
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
expect(browser.iframe(index: 0).text_field(name: 'senderElement').value).to eq "new value"
|
155
|
-
end
|
149
|
+
it "is able to set a field" do
|
150
|
+
browser.iframe(index: 0).text_field(name: 'senderElement').set("new value")
|
151
|
+
expect(browser.iframe(index: 0).text_field(name: 'senderElement').value).to eq "new value"
|
156
152
|
end
|
157
153
|
|
158
154
|
describe "#execute_script" do
|
@@ -140,24 +140,22 @@ describe "Image" do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
# Other
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
expect { browser.image(index: 1337).loaded? }.to raise_unknown_object_exception
|
160
|
-
end
|
143
|
+
describe "#loaded?" do
|
144
|
+
it "returns true if the image has been loaded" do
|
145
|
+
expect(browser.image(title: 'Circle')).to be_loaded
|
146
|
+
expect(browser.image(alt: 'circle')).to be_loaded
|
147
|
+
expect(browser.image(alt: /circle/)).to be_loaded
|
148
|
+
end
|
149
|
+
|
150
|
+
it "returns false if the image has not been loaded" do
|
151
|
+
expect(browser.image(id: 'no_such_file')).to_not be_loaded
|
152
|
+
end
|
153
|
+
|
154
|
+
it "raises UnknownObjectException if the image doesn't exist" do
|
155
|
+
expect { browser.image(id: 'no_such_image').loaded? }.to raise_unknown_object_exception
|
156
|
+
expect { browser.image(src: 'no_such_image').loaded? }.to raise_unknown_object_exception
|
157
|
+
expect { browser.image(alt: 'no_such_image').loaded? }.to raise_unknown_object_exception
|
158
|
+
expect { browser.image(index: 1337).loaded? }.to raise_unknown_object_exception
|
161
159
|
end
|
162
160
|
end
|
163
161
|
|
@@ -90,13 +90,11 @@ describe "SelectList" do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
describe "#value" do
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
expect(browser.select_list(index: 0).value).to eq "3"
|
99
|
-
end
|
93
|
+
not_compliant_on :safari do
|
94
|
+
it "returns the value of the selected option" do
|
95
|
+
expect(browser.select_list(index: 0).value).to eq "2"
|
96
|
+
browser.select_list(index: 0).select(/Sweden/)
|
97
|
+
expect(browser.select_list(index: 0).value).to eq "3"
|
100
98
|
end
|
101
99
|
end
|
102
100
|
|
@@ -185,12 +183,10 @@ describe "SelectList" do
|
|
185
183
|
end
|
186
184
|
|
187
185
|
describe "#clear" do
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
expect(browser.select_list(name: "new_user_languages").selected_options).to be_empty
|
193
|
-
end
|
186
|
+
not_compliant_on :safari do
|
187
|
+
it "clears the selection when possible" do
|
188
|
+
browser.select_list(name: "new_user_languages").clear
|
189
|
+
expect(browser.select_list(name: "new_user_languages").selected_options).to be_empty
|
194
190
|
end
|
195
191
|
end
|
196
192
|
|
@@ -207,11 +203,9 @@ describe "SelectList" do
|
|
207
203
|
end
|
208
204
|
|
209
205
|
not_compliant_on :safari do
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
expect(messages.size).to eq 2
|
214
|
-
end
|
206
|
+
it "fires onchange event" do
|
207
|
+
browser.select_list(name: "new_user_languages").clear
|
208
|
+
expect(messages.size).to eq 2
|
215
209
|
end
|
216
210
|
|
217
211
|
it "doesn't fire onchange event for already cleared option" do
|
@@ -237,22 +231,18 @@ describe "SelectList" do
|
|
237
231
|
|
238
232
|
not_compliant_on :safari do
|
239
233
|
describe "#selected?" do
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
expect(browser.select_list(name: 'new_user_country')).to be_selected('Denmark')
|
244
|
-
end
|
234
|
+
it "returns true if the given option is selected by text" do
|
235
|
+
browser.select_list(name: 'new_user_country').select('Denmark')
|
236
|
+
expect(browser.select_list(name: 'new_user_country')).to be_selected('Denmark')
|
245
237
|
end
|
246
238
|
|
247
239
|
it "returns false if the given option is not selected by text" do
|
248
240
|
expect(browser.select_list(name: 'new_user_country')).to_not be_selected('Sweden')
|
249
241
|
end
|
250
242
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
expect(browser.select_list(name: 'new_user_country')).to be_selected('Germany')
|
255
|
-
end
|
243
|
+
it "returns true if the given option is selected by label" do
|
244
|
+
browser.select_list(name: 'new_user_country').select('Germany')
|
245
|
+
expect(browser.select_list(name: 'new_user_country')).to be_selected('Germany')
|
256
246
|
end
|
257
247
|
|
258
248
|
it "returns false if the given option is not selected by label" do
|
@@ -267,51 +257,49 @@ describe "SelectList" do
|
|
267
257
|
|
268
258
|
not_compliant_on :safari do
|
269
259
|
describe "#select" do
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
expect(browser.select_list(id: "delete_user_username").selected_options.map(&:text)).to eq [""]
|
314
|
-
end
|
260
|
+
context "when interacting with options" do
|
261
|
+
it "selects the given item when given a String" do
|
262
|
+
browser.select_list(name: "new_user_country").select("Denmark")
|
263
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Denmark"]
|
264
|
+
end
|
265
|
+
|
266
|
+
it "selects options by label" do
|
267
|
+
browser.select_list(name: "new_user_country").select("Germany")
|
268
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Germany"]
|
269
|
+
end
|
270
|
+
|
271
|
+
it "selects the given item when given a Regexp" do
|
272
|
+
browser.select_list(name: "new_user_country").select(/Denmark/)
|
273
|
+
expect(browser.select_list(name: "new_user_country").selected_options.map(&:text)).to eq ["Denmark"]
|
274
|
+
end
|
275
|
+
|
276
|
+
it "selects the given item when given an Xpath" do
|
277
|
+
browser.select_list(xpath: "//select[@name='new_user_country']").select("Denmark")
|
278
|
+
expect(browser.select_list(xpath: "//select[@name='new_user_country']").selected_options.map(&:text)).to eq ["Denmark"]
|
279
|
+
end
|
280
|
+
|
281
|
+
it "selects multiple items using :name and a String" do
|
282
|
+
browser.select_list(name: "new_user_languages").clear
|
283
|
+
browser.select_list(name: "new_user_languages").select("Danish")
|
284
|
+
browser.select_list(name: "new_user_languages").select("Swedish")
|
285
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["Danish", "Swedish"]
|
286
|
+
end
|
287
|
+
|
288
|
+
it "selects multiple items using :name and a Regexp" do
|
289
|
+
browser.select_list(name: "new_user_languages").clear
|
290
|
+
browser.select_list(name: "new_user_languages").select_all(/ish/)
|
291
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq ["Danish", "English", "Swedish"]
|
292
|
+
end
|
293
|
+
|
294
|
+
it "selects multiple items using :xpath" do
|
295
|
+
browser.select_list(xpath: "//select[@name='new_user_languages']").clear
|
296
|
+
browser.select_list(xpath: "//select[@name='new_user_languages']").select_all(/ish/)
|
297
|
+
expect(browser.select_list(xpath: "//select[@name='new_user_languages']").selected_options.map(&:text)).to eq ["Danish", "English", "Swedish"]
|
298
|
+
end
|
299
|
+
|
300
|
+
it "selects empty options" do
|
301
|
+
browser.select_list(id: "delete_user_username").select("")
|
302
|
+
expect(browser.select_list(id: "delete_user_username").selected_options.map(&:text)).to eq [""]
|
315
303
|
end
|
316
304
|
end
|
317
305
|
end
|
@@ -330,15 +318,13 @@ describe "SelectList" do
|
|
330
318
|
expect(messages).to eq ['changed language']
|
331
319
|
end
|
332
320
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
expect(messages.size).to eq 3
|
321
|
+
it "doesn't fire onchange event when selecting an already selected item" do
|
322
|
+
browser.select_list(id: "new_user_languages").clear # removes the two pre-selected options
|
323
|
+
browser.select_list(id: "new_user_languages").select("English")
|
324
|
+
expect(messages.size).to eq 3
|
338
325
|
|
339
|
-
|
340
|
-
|
341
|
-
end
|
326
|
+
browser.select_list(id: "new_user_languages").select("English")
|
327
|
+
expect(messages.size).to eq 3
|
342
328
|
end
|
343
329
|
end
|
344
330
|
|
@@ -346,11 +332,9 @@ describe "SelectList" do
|
|
346
332
|
expect(browser.select_list(id: "new_user_languages").select("English")).to eq "English"
|
347
333
|
end
|
348
334
|
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
expect(browser.select_list(id: 'obsolete').select('sweden')).to eq ''
|
353
|
-
end
|
335
|
+
not_compliant_on :safari do
|
336
|
+
it "returns an empty string when selecting an option that disappears when selected" do
|
337
|
+
expect(browser.select_list(id: 'obsolete').select('sweden')).to eq ''
|
354
338
|
end
|
355
339
|
end
|
356
340
|
|
@@ -381,12 +365,10 @@ describe "SelectList" do
|
|
381
365
|
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq %w[English]
|
382
366
|
end
|
383
367
|
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq %w[Danish Norwegian]
|
389
|
-
end
|
368
|
+
it "selects the items by value regexp" do
|
369
|
+
browser.select_list(name: "new_user_languages").clear
|
370
|
+
browser.select_list(name: "new_user_languages").select_value(/1|3/)
|
371
|
+
expect(browser.select_list(name: "new_user_languages").selected_options.map(&:text)).to eq %w[Danish Norwegian]
|
390
372
|
end
|
391
373
|
|
392
374
|
it "raises NoValueFoundException if the option doesn't exist" do
|
@@ -183,11 +183,9 @@ describe "TextField" do
|
|
183
183
|
end
|
184
184
|
|
185
185
|
describe "#readonly?" do
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
expect(browser.text_field(id: "new_user_code")).to be_readonly
|
190
|
-
end
|
186
|
+
it "returns true for read-only text fields" do
|
187
|
+
expect(browser.text_field(name: "new_user_code")).to be_readonly
|
188
|
+
expect(browser.text_field(id: "new_user_code")).to be_readonly
|
191
189
|
end
|
192
190
|
|
193
191
|
it "returns false for writable text fields" do
|
@@ -242,10 +240,8 @@ describe "TextField" do
|
|
242
240
|
expect { browser.text_field(id: "no_such_id").clear }.to raise_unknown_object_exception
|
243
241
|
end
|
244
242
|
|
245
|
-
|
246
|
-
|
247
|
-
expect { browser.text_field(id: "new_user_code").clear }.to raise_object_read_only_exception
|
248
|
-
end
|
243
|
+
it "raises ObjectReadOnlyException if the object is read only" do
|
244
|
+
expect { browser.text_field(id: "new_user_code").clear }.to raise_object_read_only_exception
|
249
245
|
end
|
250
246
|
end
|
251
247
|
|
@@ -36,11 +36,9 @@ describe "TableRow" do
|
|
36
36
|
|
37
37
|
describe "#click" do
|
38
38
|
bug "http://github.com/watir/watir/issues/issue/32", :internet_explorer, :chrome do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
expect(messages).to include('tr')
|
43
|
-
end
|
39
|
+
it "fires the row's onclick event" do
|
40
|
+
browser.tr(id: 'inner_first').click
|
41
|
+
expect(messages).to include('tr')
|
44
42
|
end
|
45
43
|
end
|
46
44
|
end
|
@@ -108,27 +108,25 @@ describe "Window" do
|
|
108
108
|
browser.windows[1..-1].each(&:close)
|
109
109
|
end
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
it "closes a window" do
|
115
|
-
browser.a(id: "open").click
|
116
|
-
Watir::Wait.until { browser.windows.size == 3 }
|
117
|
-
|
118
|
-
browser.window(title: "closeable window").close
|
119
|
-
expect(browser.windows.size).to eq 2
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
it "closes the current window" do
|
111
|
+
not_compliant_on :safari, %i(firefox linux) do
|
112
|
+
describe "#close" do
|
113
|
+
it "closes a window" do
|
124
114
|
browser.a(id: "open").click
|
125
115
|
Watir::Wait.until { browser.windows.size == 3 }
|
126
116
|
|
127
|
-
|
128
|
-
window.close
|
117
|
+
browser.window(title: "closeable window").close
|
129
118
|
expect(browser.windows.size).to eq 2
|
130
119
|
end
|
131
120
|
end
|
121
|
+
|
122
|
+
it "closes the current window" do
|
123
|
+
browser.a(id: "open").click
|
124
|
+
Watir::Wait.until { browser.windows.size == 3 }
|
125
|
+
|
126
|
+
window = browser.window(title: "closeable window").use
|
127
|
+
window.close
|
128
|
+
expect(browser.windows.size).to eq 2
|
129
|
+
end
|
132
130
|
end
|
133
131
|
|
134
132
|
describe "#use" do
|
@@ -256,21 +254,19 @@ describe "Window" do
|
|
256
254
|
|
257
255
|
not_compliant_on :headless do
|
258
256
|
describe "#use" do
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
end
|
257
|
+
it "raises NoMatchingWindowFoundException error when attempting to use a referenced window that is closed" do
|
258
|
+
original_window = browser.window
|
259
|
+
browser.window(index: 1).use
|
260
|
+
original_window.close
|
261
|
+
expect { original_window.use }.to raise_no_matching_window_exception
|
262
|
+
end
|
266
263
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
end
|
264
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1223277", :firefox do
|
265
|
+
it "raises NoMatchingWindowFoundException error when attempting to use the current window if it is closed" do
|
266
|
+
browser.window(title: "closeable window").use
|
267
|
+
browser.a(id: "close").click
|
268
|
+
Watir::Wait.until { browser.windows.size == 1 }
|
269
|
+
expect { browser.window.use }.to raise_no_matching_window_exception
|
274
270
|
end
|
275
271
|
end
|
276
272
|
end
|
@@ -351,22 +347,20 @@ describe "Window" do
|
|
351
347
|
browser.goto WatirSpec.url_for("window_switching.html")
|
352
348
|
end
|
353
349
|
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
size = browser.window.size
|
350
|
+
not_compliant_on :headless do
|
351
|
+
it "should get the size of the current window" do
|
352
|
+
size = browser.window.size
|
358
353
|
|
359
|
-
|
360
|
-
|
361
|
-
end
|
354
|
+
expect(size.width).to be > 0
|
355
|
+
expect(size.height).to be > 0
|
362
356
|
end
|
357
|
+
end
|
363
358
|
|
364
|
-
|
365
|
-
|
359
|
+
it "should get the position of the current window" do
|
360
|
+
pos = browser.window.position
|
366
361
|
|
367
|
-
|
368
|
-
|
369
|
-
end
|
362
|
+
expect(pos.x).to be >= 0
|
363
|
+
expect(pos.y).to be >= 0
|
370
364
|
end
|
371
365
|
|
372
366
|
not_compliant_on :headless do
|
@@ -386,7 +380,7 @@ describe "Window" do
|
|
386
380
|
end
|
387
381
|
end
|
388
382
|
|
389
|
-
not_compliant_on :
|
383
|
+
not_compliant_on :headless, %i(remote firefox) do
|
390
384
|
it "should move the window" do
|
391
385
|
initial_pos = browser.window.position
|
392
386
|
|
@@ -403,7 +397,7 @@ describe "Window" do
|
|
403
397
|
|
404
398
|
not_compliant_on :headless do
|
405
399
|
compliant_on :window_manager do
|
406
|
-
bug "https://github.com/SeleniumHQ/selenium/issues/2856",
|
400
|
+
bug "https://github.com/SeleniumHQ/selenium/issues/2856", :firefox do
|
407
401
|
it "should maximize the window" do
|
408
402
|
initial_size = browser.window.size
|
409
403
|
browser.window.resize_to(
|
data/support/doctest_helper.rb
CHANGED
data/watir.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.6.
|
4
|
+
version: 6.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-08-
|
12
|
+
date: 2017-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|