watir 6.5.0 → 6.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +58 -21
- data/CHANGES.md +11 -0
- data/Rakefile +3 -5
- data/lib/watir.rb +14 -2
- data/lib/watir/adjacent.rb +20 -27
- data/lib/watir/alert.rb +1 -1
- data/lib/watir/attribute_helper.rb +1 -1
- data/lib/watir/browser.rb +6 -3
- data/lib/watir/capabilities.rb +95 -0
- data/lib/watir/cookies.rb +5 -6
- data/lib/watir/element_collection.rb +17 -0
- data/lib/watir/elements/element.rb +12 -15
- data/lib/watir/elements/iframe.rb +1 -1
- data/lib/watir/elements/option.rb +5 -6
- data/lib/watir/elements/select.rb +52 -36
- data/lib/watir/legacy_wait.rb +2 -2
- data/lib/watir/locators/button/selector_builder.rb +10 -7
- data/lib/watir/locators/element/locator.rb +2 -2
- data/lib/watir/locators/element/selector_builder.rb +10 -4
- data/lib/watir/locators/element/selector_builder/xpath.rb +22 -3
- data/lib/watir/logger.rb +109 -0
- data/lib/watir/wait.rb +6 -6
- data/lib/watirspec.rb +1 -1
- data/lib/watirspec/guards.rb +4 -4
- data/lib/watirspec/implementation.rb +13 -5
- data/lib/watirspec/remote_server.rb +38 -0
- data/lib/watirspec/runner.rb +2 -2
- data/lib/watirspec/server.rb +1 -1
- data/spec/browser_spec.rb +101 -17
- data/spec/element_locator_spec.rb +1 -1
- data/spec/element_spec.rb +1 -1
- data/spec/logger_spec.rb +46 -0
- data/spec/watirspec/adjacent_spec.rb +45 -0
- data/spec/watirspec/after_hooks_spec.rb +45 -40
- data/spec/watirspec/alert_spec.rb +20 -14
- data/spec/watirspec/browser_spec.rb +71 -77
- data/spec/watirspec/cookies_spec.rb +13 -16
- data/spec/watirspec/drag_and_drop_spec.rb +6 -6
- data/spec/watirspec/elements/button_spec.rb +14 -7
- data/spec/watirspec/elements/collections_spec.rb +18 -1
- data/spec/watirspec/elements/dd_spec.rb +4 -2
- data/spec/watirspec/elements/del_spec.rb +12 -10
- data/spec/watirspec/elements/div_spec.rb +17 -13
- data/spec/watirspec/elements/dl_spec.rb +4 -2
- data/spec/watirspec/elements/form_spec.rb +8 -6
- data/spec/watirspec/elements/frame_spec.rb +27 -19
- data/spec/watirspec/elements/iframe_spec.rb +28 -17
- data/spec/watirspec/elements/ins_spec.rb +12 -10
- data/spec/watirspec/elements/option_spec.rb +17 -33
- data/spec/watirspec/elements/select_list_spec.rb +111 -97
- data/spec/watirspec/elements/span_spec.rb +12 -10
- data/spec/watirspec/elements/table_spec.rb +13 -11
- data/spec/watirspec/elements/tbody_spec.rb +13 -11
- data/spec/watirspec/elements/td_spec.rb +6 -4
- data/spec/watirspec/elements/text_field_spec.rb +19 -17
- data/spec/watirspec/elements/tr_spec.rb +12 -8
- data/spec/watirspec/html/javascript/helpers.js +2 -2
- data/spec/watirspec/html/nested_elements.html +5 -5
- data/spec/watirspec/relaxed_locate_spec.rb +13 -19
- data/spec/watirspec/wait_spec.rb +279 -301
- data/spec/watirspec/window_switching_spec.rb +190 -174
- data/spec/watirspec_helper.rb +64 -122
- data/support/doctest_helper.rb +4 -0
- data/watir.gemspec +2 -2
- metadata +15 -4
@@ -71,40 +71,38 @@ describe "Browser::AfterHooks" do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
bug "AutomatedTester: 'known bug with execute script'", :firefox do
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
browser.form(id: "new_user").submit
|
79
|
-
expect(@yield).to be true
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
not_compliant_on :safari do
|
84
|
-
bug "Actions Endpoint Not Yet Implemented", :firefox do
|
85
|
-
it "runs after_hooks after Element#double_click" do
|
86
|
-
browser.goto(WatirSpec.url_for("non_control_elements.html"))
|
87
|
-
@page_after_hook = Proc.new { @yield = browser.title == "Non-control elements" }
|
74
|
+
not_compliant_on :safari do
|
75
|
+
it "runs after_hooks after Element#submit" do
|
76
|
+
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
|
77
|
+
@page_after_hook = Proc.new { @yield = browser.div(id: 'messages').text == 'submit' }
|
88
78
|
browser.after_hooks.add @page_after_hook
|
89
|
-
browser.
|
79
|
+
browser.form(id: "new_user").submit
|
90
80
|
expect(@yield).to be true
|
91
81
|
end
|
92
82
|
end
|
93
83
|
end
|
94
84
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
85
|
+
bug "Actions Endpoint Not Yet Implemented", :firefox do
|
86
|
+
it "runs after_hooks after Element#double_click" do
|
87
|
+
browser.goto(WatirSpec.url_for("non_control_elements.html"))
|
88
|
+
@page_after_hook = Proc.new { @yield = browser.title == "Non-control elements" }
|
89
|
+
browser.after_hooks.add @page_after_hook
|
90
|
+
browser.div(id: 'html_test').double_click
|
91
|
+
expect(@yield).to be true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
bug "Actions Endpoint Not Yet Implemented", :firefox do
|
96
|
+
it "runs after_hooks after Element#right_click" do
|
97
|
+
browser.goto(WatirSpec.url_for("right_click.html"))
|
98
|
+
@page_after_hook = Proc.new { @yield = browser.title == "Right Click Test" }
|
99
|
+
browser.after_hooks.add @page_after_hook
|
100
|
+
browser.div(id: "click").right_click
|
101
|
+
expect(@yield).to be true
|
104
102
|
end
|
105
103
|
end
|
106
104
|
|
107
|
-
not_compliant_on :
|
105
|
+
not_compliant_on :headless do
|
108
106
|
it "runs after_hooks after Alert#ok" do
|
109
107
|
browser.goto(WatirSpec.url_for("alerts.html"))
|
110
108
|
@page_after_hook = Proc.new { @yield = browser.title == "Alerts" }
|
@@ -113,7 +111,9 @@ describe "Browser::AfterHooks" do
|
|
113
111
|
browser.alert.ok
|
114
112
|
expect(@yield).to be true
|
115
113
|
end
|
114
|
+
end
|
116
115
|
|
116
|
+
not_compliant_on :headless do
|
117
117
|
bug "https://code.google.com/p/chromedriver/issues/detail?id=26", [:chrome, :macosx] do
|
118
118
|
it "runs after_hooks after Alert#close" do
|
119
119
|
browser.goto(WatirSpec.url_for("alerts.html"))
|
@@ -124,21 +124,22 @@ describe "Browser::AfterHooks" do
|
|
124
124
|
expect(@yield).to be true
|
125
125
|
end
|
126
126
|
end
|
127
|
+
end
|
127
128
|
|
128
|
-
|
129
|
+
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1279211", :firefox do
|
130
|
+
not_compliant_on :safari, :headless do
|
129
131
|
it "raises UnhandledAlertError error when running error checks with alert present" do
|
130
132
|
url = WatirSpec.url_for("alerts.html")
|
131
133
|
@page_after_hook = Proc.new { browser.url }
|
132
134
|
browser.after_hooks.add @page_after_hook
|
133
135
|
browser.goto url
|
134
136
|
expect { browser.button(id: "alert").click }.to raise_error(Selenium::WebDriver::Error::UnhandledAlertError)
|
135
|
-
|
136
|
-
not_compliant_on :ff_legacy do
|
137
|
-
browser.alert.ok
|
138
|
-
end
|
137
|
+
browser.alert.ok
|
139
138
|
end
|
140
139
|
end
|
140
|
+
end
|
141
141
|
|
142
|
+
not_compliant_on :headless do
|
142
143
|
it "does not raise error when running error checks using #after_hooks#without with alert present" do
|
143
144
|
url = WatirSpec.url_for("alerts.html")
|
144
145
|
@page_after_hook = Proc.new { browser.url }
|
@@ -147,7 +148,9 @@ describe "Browser::AfterHooks" do
|
|
147
148
|
expect { browser.after_hooks.without { browser.button(id: "alert").click } }.to_not raise_error
|
148
149
|
browser.alert.ok
|
149
150
|
end
|
151
|
+
end
|
150
152
|
|
153
|
+
not_compliant_on :headless do
|
151
154
|
it "does not raise error if no error checks are defined with alert present" do
|
152
155
|
url = WatirSpec.url_for("alerts.html")
|
153
156
|
@page_after_hook = Proc.new { browser.url }
|
@@ -160,17 +163,19 @@ describe "Browser::AfterHooks" do
|
|
160
163
|
end
|
161
164
|
|
162
165
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1223277", :firefox do
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
166
|
+
not_compliant_on :headless do
|
167
|
+
it "does not raise error when running error checks on closed window" do
|
168
|
+
url = WatirSpec.url_for("window_switching.html")
|
169
|
+
@page_after_hook = Proc.new { browser.url }
|
170
|
+
browser.after_hooks.add @page_after_hook
|
171
|
+
browser.goto url
|
172
|
+
browser.a(id: "open").click
|
169
173
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
+
window = browser.window(title: "closeable window")
|
175
|
+
window.use
|
176
|
+
expect { browser.a(id: "close").click }.to_not raise_error
|
177
|
+
browser.window(index: 0).use
|
178
|
+
end
|
174
179
|
end
|
175
180
|
end
|
176
181
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "watirspec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
not_compliant_on :headless do
|
4
|
+
describe 'Alert API' do
|
5
5
|
before do
|
6
6
|
browser.goto WatirSpec.url_for("alerts.html")
|
7
7
|
end
|
@@ -23,26 +23,32 @@ describe 'Alert API' do
|
|
23
23
|
expect(browser.alert).to_not exist
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
bug "Alert exception not thrown, so Browser#inspect hangs", :safari do
|
27
|
+
it 'returns true if alert is present' do
|
28
|
+
browser.button(id: 'alert').click
|
29
|
+
browser.wait_until(timeout: 10) { browser.alert.exists? }
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
34
|
describe '#ok' do
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
not_compliant_on :safari do
|
36
|
+
it 'closes alert' do
|
37
|
+
browser.button(id: 'alert').click
|
38
|
+
browser.alert.ok
|
39
|
+
expect(browser.alert).to_not exist
|
40
|
+
end
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
40
44
|
bug "https://code.google.com/p/chromedriver/issues/detail?id=26", [:chrome, :macosx] do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
not_compliant_on :safari do
|
46
|
+
describe '#close' do
|
47
|
+
it 'closes alert' do
|
48
|
+
browser.button(id: 'alert').click
|
49
|
+
browser.alert.close
|
50
|
+
expect(browser.alert).to_not exist
|
51
|
+
end
|
46
52
|
end
|
47
53
|
end
|
48
54
|
end
|
@@ -14,22 +14,24 @@ describe "Browser" do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1223277", :firefox do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
not_compliant_on :headless do
|
18
|
+
it "returns false if window is closed" do
|
19
|
+
browser.goto WatirSpec.url_for("window_switching.html")
|
20
|
+
browser.a(id: "open").click
|
21
|
+
Watir::Wait.until { browser.windows.size == 2 }
|
22
|
+
browser.window(title: "closeable window").use
|
23
|
+
browser.a(id: "close").click
|
24
|
+
Watir::Wait.until { browser.windows.size == 1 }
|
25
|
+
expect(browser.exists?).to be false
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
30
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1290814", :firefox do
|
29
31
|
it "returns false after Browser#close" do
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
browser.close
|
33
|
+
expect(browser).to_not exist
|
34
|
+
$browser = WatirSpec.new_browser
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
@@ -95,10 +97,12 @@ describe "Browser" do
|
|
95
97
|
expect(browser.text.strip).to eq 'This is text/plain'
|
96
98
|
end
|
97
99
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
100
|
+
bug "Safari does not strip text", :safari do
|
101
|
+
it "returns text of top most browsing context" do
|
102
|
+
browser.goto(WatirSpec.url_for("nested_iframes.html"))
|
103
|
+
browser.iframe(id: 'two').h3.exists?
|
104
|
+
expect(browser.text).to eq 'Top Layer'
|
105
|
+
end
|
102
106
|
end
|
103
107
|
end
|
104
108
|
|
@@ -132,12 +136,14 @@ describe "Browser" do
|
|
132
136
|
describe ".start" do
|
133
137
|
bug "https://bugzilla.mozilla.org/show_bug.cgi?id=1290814", :firefox do
|
134
138
|
it "goes to the given URL and return an instance of itself" do
|
139
|
+
browser.close
|
135
140
|
driver, args = WatirSpec.implementation.browser_args
|
136
|
-
|
141
|
+
b = Watir::Browser.start(WatirSpec.url_for("non_control_elements.html"), driver, args.dup)
|
137
142
|
|
138
|
-
expect(
|
139
|
-
expect(
|
140
|
-
|
143
|
+
expect(b).to be_instance_of(Watir::Browser)
|
144
|
+
expect(b.title).to eq "Non-control elements"
|
145
|
+
b.close
|
146
|
+
$browser = WatirSpec.new_browser
|
141
147
|
end
|
142
148
|
end
|
143
149
|
end
|
@@ -160,24 +166,12 @@ describe "Browser" do
|
|
160
166
|
expect { browser.goto("about:blank") }.to_not raise_error
|
161
167
|
end
|
162
168
|
|
163
|
-
not_compliant_on :internet_explorer
|
169
|
+
not_compliant_on :internet_explorer do
|
164
170
|
it "goes to a data URL scheme address without raising errors" do
|
165
171
|
expect { browser.goto("data:text/html;content-type=utf-8,foobar") }.to_not raise_error
|
166
172
|
end
|
167
173
|
end
|
168
174
|
|
169
|
-
compliant_on :ff_legacy do
|
170
|
-
it "goes to internal Firefox URL 'about:mozilla' without raising errors" do
|
171
|
-
expect { browser.goto("about:mozilla") }.to_not raise_error
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
compliant_on :opera do
|
176
|
-
it "goes to internal Opera URL 'opera:config' without raising errors" do
|
177
|
-
expect { browser.goto("opera:config") }.to_not raise_error
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
175
|
compliant_on :chrome do
|
182
176
|
it "goes to internal Chrome URL 'chrome://settings/browser' without raising errors" do
|
183
177
|
expect { browser.goto("chrome://settings/browser") }.to_not raise_error
|
@@ -191,14 +185,16 @@ describe "Browser" do
|
|
191
185
|
end
|
192
186
|
end
|
193
187
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
188
|
+
not_compliant_on :headless do
|
189
|
+
describe "#refresh" do
|
190
|
+
it "refreshes the page" do
|
191
|
+
browser.goto(WatirSpec.url_for("non_control_elements.html"))
|
192
|
+
browser.span(class: 'footer').click
|
193
|
+
expect(browser.span(class: 'footer').text).to include('Javascript')
|
194
|
+
browser.refresh
|
195
|
+
browser.span(class: 'footer').wait_until_present
|
196
|
+
expect(browser.span(class: 'footer').text).to_not include('Javascript')
|
197
|
+
end
|
202
198
|
end
|
203
199
|
end
|
204
200
|
|
@@ -240,46 +236,44 @@ describe "Browser" do
|
|
240
236
|
end
|
241
237
|
end
|
242
238
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
end
|
254
|
-
|
255
|
-
it "goes to the next page" do
|
256
|
-
urls = []
|
257
|
-
browser.goto WatirSpec.url_for("non_control_elements.html")
|
258
|
-
urls << browser.url
|
259
|
-
browser.goto WatirSpec.url_for("tables.html")
|
260
|
-
urls << browser.url
|
261
|
-
|
262
|
-
browser.back
|
263
|
-
expect(browser.url).to eq urls.first
|
264
|
-
browser.forward
|
265
|
-
expect(browser.url).to eq urls.last
|
266
|
-
end
|
239
|
+
describe "#back and #forward" do
|
240
|
+
it "goes to the previous page" do
|
241
|
+
browser.goto WatirSpec.url_for("non_control_elements.html")
|
242
|
+
orig_url = browser.url
|
243
|
+
browser.goto WatirSpec.url_for("tables.html")
|
244
|
+
new_url = browser.url
|
245
|
+
expect(orig_url).to_not eq new_url
|
246
|
+
browser.back
|
247
|
+
expect(orig_url).to eq browser.url
|
248
|
+
end
|
267
249
|
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
250
|
+
it "goes to the next page" do
|
251
|
+
urls = []
|
252
|
+
browser.goto WatirSpec.url_for("non_control_elements.html")
|
253
|
+
urls << browser.url
|
254
|
+
browser.goto WatirSpec.url_for("tables.html")
|
255
|
+
urls << browser.url
|
256
|
+
|
257
|
+
browser.back
|
258
|
+
expect(browser.url).to eq urls.first
|
259
|
+
browser.forward
|
260
|
+
expect(browser.url).to eq urls.last
|
261
|
+
end
|
277
262
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
263
|
+
it "navigates between several history items" do
|
264
|
+
urls = ["non_control_elements.html",
|
265
|
+
"tables.html",
|
266
|
+
"forms_with_input_elements.html",
|
267
|
+
"definition_lists.html"
|
268
|
+
].map do |page|
|
269
|
+
browser.goto WatirSpec.url_for(page)
|
270
|
+
browser.url
|
282
271
|
end
|
272
|
+
|
273
|
+
3.times { browser.back }
|
274
|
+
expect(browser.url).to eq urls.first
|
275
|
+
2.times { browser.forward }
|
276
|
+
expect(browser.url).to eq urls[2]
|
283
277
|
end
|
284
278
|
end
|
285
279
|
|
@@ -48,11 +48,6 @@ describe "Browser#cookies" do
|
|
48
48
|
|
49
49
|
browser.cookies.add 'foo', 'bar'
|
50
50
|
verify_cookies_count 2
|
51
|
-
|
52
|
-
compliant_on :safari do
|
53
|
-
$browser.close
|
54
|
-
$browser = WatirSpec.new_browser
|
55
|
-
end
|
56
51
|
end
|
57
52
|
end
|
58
53
|
|
@@ -118,17 +113,19 @@ describe "Browser#cookies" do
|
|
118
113
|
end
|
119
114
|
|
120
115
|
describe '#load' do
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
116
|
+
bug "invalid expiration issue", :firefox do
|
117
|
+
it 'loads cookies from file' do
|
118
|
+
browser.cookies.clear
|
119
|
+
browser.cookies.load file
|
120
|
+
expected = browser.cookies.to_a
|
121
|
+
actual = YAML.load(IO.read(file))
|
122
|
+
|
123
|
+
# https://code.google.com/p/selenium/issues/detail?id=6834
|
124
|
+
expected.each { |cookie| cookie.delete(:expires) }
|
125
|
+
actual.each { |cookie| cookie.delete(:expires) }
|
126
|
+
|
127
|
+
expect(actual).to eq(expected)
|
128
|
+
end
|
132
129
|
end
|
133
130
|
end
|
134
131
|
end
|
@@ -2,20 +2,20 @@ require "watirspec_helper"
|
|
2
2
|
|
3
3
|
describe "Element" do
|
4
4
|
bug "Actions Endpoint Not Yet Implemented", :firefox do
|
5
|
-
|
6
|
-
|
5
|
+
bug "Safari does not strip text", :safari do
|
6
|
+
context "drag and drop" do
|
7
|
+
before { browser.goto WatirSpec.url_for("drag_and_drop.html") }
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
let(:draggable) { browser.div id: "draggable" }
|
10
|
+
let(:droppable) { browser.div id: "droppable" }
|
10
11
|
|
11
|
-
not_compliant_on :safari do
|
12
12
|
it "can drag and drop an element onto another" do
|
13
13
|
expect(droppable.text).to eq 'Drop here'
|
14
14
|
draggable.drag_and_drop_on droppable
|
15
15
|
expect(droppable.text).to eq 'Dropped!'
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
not_compliant_on :headless 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
|