watir 7.2.0 → 7.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/chrome.yml +1 -1
- data/.github/workflows/edge.yml +1 -1
- data/.github/workflows/firefox.yml +1 -1
- data/.github/workflows/ie.yml +1 -1
- data/.github/workflows/safari.yml +1 -1
- data/.github/workflows/unit.yml +1 -1
- data/.rubocop.yml +25 -12
- data/.rubocop_todo.yml +8 -1
- data/CHANGES.md +6 -1
- data/LICENSE +2 -2
- data/lib/watir/capabilities.rb +1 -1
- data/lib/watir/locators/anchor/selector_builder.rb +3 -0
- data/lib/watir/locators/element/matcher.rb +2 -1
- data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +2 -1
- data/lib/watir/locators/text_field/matcher.rb +0 -4
- data/lib/watir/version.rb +1 -1
- data/spec/locator_spec_helper.rb +0 -8
- data/spec/unit/capabilities_spec.rb +553 -561
- data/spec/unit/element_locator_spec.rb +89 -78
- data/spec/unit/match_elements/button_spec.rb +69 -62
- data/spec/unit/match_elements/element_spec.rb +303 -309
- data/spec/unit/match_elements/text_field_spec.rb +76 -73
- data/spec/unit/selector_builder/anchor_spec.rb +39 -33
- data/spec/unit/selector_builder/button_spec.rb +209 -202
- data/spec/unit/selector_builder/cell_spec.rb +48 -42
- data/spec/unit/selector_builder/element_spec.rb +634 -627
- data/spec/unit/selector_builder/row_spec.rb +119 -113
- data/spec/unit/selector_builder/text_field_spec.rb +195 -188
- data/spec/unit/selector_builder/textarea_spec.rb +22 -14
- data/spec/unit/wait_spec.rb +85 -81
- data/spec/watirspec/adjacent_spec.rb +249 -247
- data/spec/watirspec/after_hooks_spec.rb +161 -159
- data/spec/watirspec/alert_spec.rb +61 -58
- data/spec/watirspec/browser_spec.rb +409 -409
- data/spec/watirspec/capabilities_spec.rb +89 -99
- data/spec/watirspec/cookies_spec.rb +120 -118
- data/spec/watirspec/drag_and_drop_spec.rb +26 -24
- data/spec/watirspec/element_hidden_spec.rb +66 -60
- data/spec/watirspec/elements/area_spec.rb +49 -47
- data/spec/watirspec/elements/areas_spec.rb +27 -25
- data/spec/watirspec/elements/button_spec.rb +253 -251
- data/spec/watirspec/elements/buttons_spec.rb +36 -34
- data/spec/watirspec/elements/checkbox_spec.rb +48 -36
- data/spec/watirspec/elements/checkboxes_spec.rb +29 -27
- data/spec/watirspec/elements/collections_spec.rb +126 -119
- data/spec/watirspec/elements/date_field_spec.rb +185 -183
- data/spec/watirspec/elements/date_fields_spec.rb +29 -27
- data/spec/watirspec/elements/date_time_field_spec.rb +197 -195
- data/spec/watirspec/elements/date_time_fields_spec.rb +30 -28
- data/spec/watirspec/elements/dd_spec.rb +87 -85
- data/spec/watirspec/elements/dds_spec.rb +27 -25
- data/spec/watirspec/elements/del_spec.rb +106 -104
- data/spec/watirspec/elements/dels_spec.rb +26 -24
- data/spec/watirspec/elements/div_spec.rb +225 -221
- data/spec/watirspec/elements/divs_spec.rb +37 -35
- data/spec/watirspec/elements/dl_spec.rb +110 -108
- data/spec/watirspec/elements/dls_spec.rb +28 -26
- data/spec/watirspec/elements/dt_spec.rb +86 -84
- data/spec/watirspec/elements/dts_spec.rb +27 -25
- data/spec/watirspec/elements/element_spec.rb +794 -775
- data/spec/watirspec/elements/elements_spec.rb +40 -38
- data/spec/watirspec/elements/em_spec.rb +62 -60
- data/spec/watirspec/elements/ems_spec.rb +28 -26
- data/spec/watirspec/elements/filefield_spec.rb +116 -114
- data/spec/watirspec/elements/filefields_spec.rb +28 -26
- data/spec/watirspec/elements/font_spec.rb +20 -18
- data/spec/watirspec/elements/form_spec.rb +51 -49
- data/spec/watirspec/elements/forms_spec.rb +29 -27
- data/spec/watirspec/elements/frame_spec.rb +89 -87
- data/spec/watirspec/elements/frames_spec.rb +27 -25
- data/spec/watirspec/elements/hidden_spec.rb +81 -79
- data/spec/watirspec/elements/hiddens_spec.rb +28 -26
- data/spec/watirspec/elements/hn_spec.rb +59 -57
- data/spec/watirspec/elements/hns_spec.rb +26 -24
- data/spec/watirspec/elements/iframe_spec.rb +195 -191
- data/spec/watirspec/elements/iframes_spec.rb +31 -29
- data/spec/watirspec/elements/image_spec.rb +148 -146
- data/spec/watirspec/elements/images_spec.rb +26 -24
- data/spec/watirspec/elements/input_spec.rb +9 -7
- data/spec/watirspec/elements/ins_spec.rb +106 -104
- data/spec/watirspec/elements/inses_spec.rb +26 -24
- data/spec/watirspec/elements/label_spec.rb +56 -54
- data/spec/watirspec/elements/labels_spec.rb +26 -24
- data/spec/watirspec/elements/li_spec.rb +76 -74
- data/spec/watirspec/elements/link_spec.rb +173 -177
- data/spec/watirspec/elements/links_spec.rb +45 -43
- data/spec/watirspec/elements/lis_spec.rb +27 -25
- data/spec/watirspec/elements/list_spec.rb +44 -42
- data/spec/watirspec/elements/map_spec.rb +57 -55
- data/spec/watirspec/elements/maps_spec.rb +27 -25
- data/spec/watirspec/elements/meta_spec.rb +16 -14
- data/spec/watirspec/elements/metas_spec.rb +26 -24
- data/spec/watirspec/elements/ol_spec.rb +56 -65
- data/spec/watirspec/elements/ols_spec.rb +26 -24
- data/spec/watirspec/elements/option_spec.rb +91 -89
- data/spec/watirspec/elements/p_spec.rb +81 -79
- data/spec/watirspec/elements/pre_spec.rb +77 -75
- data/spec/watirspec/elements/pres_spec.rb +26 -24
- data/spec/watirspec/elements/ps_spec.rb +26 -24
- data/spec/watirspec/elements/radio_spec.rb +251 -249
- data/spec/watirspec/elements/radios_spec.rb +28 -26
- data/spec/watirspec/elements/select_list_spec.rb +537 -526
- data/spec/watirspec/elements/select_lists_spec.rb +32 -30
- data/spec/watirspec/elements/span_spec.rb +112 -110
- data/spec/watirspec/elements/spans_spec.rb +26 -24
- data/spec/watirspec/elements/strong_spec.rb +58 -58
- data/spec/watirspec/elements/strongs_spec.rb +28 -26
- data/spec/watirspec/elements/table_spec.rb +192 -139
- data/spec/watirspec/elements/tables_spec.rb +28 -26
- data/spec/watirspec/elements/tbody_spec.rb +74 -72
- data/spec/watirspec/elements/tbodys_spec.rb +40 -38
- data/spec/watirspec/elements/td_spec.rb +66 -64
- data/spec/watirspec/elements/tds_spec.rb +41 -39
- data/spec/watirspec/elements/text_field_spec.rb +206 -204
- data/spec/watirspec/elements/text_fields_spec.rb +30 -28
- data/spec/watirspec/elements/textarea_spec.rb +20 -18
- data/spec/watirspec/elements/textareas_spec.rb +18 -16
- data/spec/watirspec/elements/tfoot_spec.rb +65 -63
- data/spec/watirspec/elements/tfoots_spec.rb +42 -40
- data/spec/watirspec/elements/thead_spec.rb +65 -63
- data/spec/watirspec/elements/theads_spec.rb +42 -40
- data/spec/watirspec/elements/tr_spec.rb +48 -46
- data/spec/watirspec/elements/trs_spec.rb +42 -40
- data/spec/watirspec/elements/ul_spec.rb +56 -54
- data/spec/watirspec/elements/uls_spec.rb +26 -24
- data/spec/watirspec/radio_set_spec.rb +269 -267
- data/spec/watirspec/screenshot_spec.rb +20 -18
- data/spec/watirspec/scroll_spec.rb +152 -148
- data/spec/watirspec/shadow_root_spec.rb +86 -83
- data/spec/watirspec/user_editable_spec.rb +200 -198
- data/spec/watirspec/wait_spec.rb +289 -295
- data/spec/watirspec/window_switching_spec.rb +422 -434
- data/spec/watirspec_helper.rb +1 -23
- data/watir.gemspec +5 -4
- metadata +44 -33
- data/spec/watirspec/attributes_spec.rb +0 -18
- data/spec/watirspec/elements/table_nesting_spec.rb +0 -51
- data/spec/watirspec/special_chars_spec.rb +0 -23
@@ -2,201 +2,203 @@
|
|
2
2
|
|
3
3
|
require 'watirspec_helper'
|
4
4
|
|
5
|
-
|
6
|
-
describe
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
module Watir
|
6
|
+
describe AfterHooks do
|
7
|
+
describe '#add' do
|
8
|
+
it 'raises ArgumentError when not given any arguments' do
|
9
|
+
expect { browser.after_hooks.add }.to raise_error(ArgumentError)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'runs the given proc on each page load' do
|
13
|
+
proc = proc { |browser| @output = browser.text }
|
10
14
|
|
11
|
-
|
12
|
-
|
15
|
+
begin
|
16
|
+
browser.alert.dismiss if browser.alert.exists?
|
17
|
+
browser.after_hooks.add(proc)
|
18
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
20
|
+
expect(@output).to include('Dubito, ergo cogito, ergo sum')
|
21
|
+
ensure
|
22
|
+
browser.after_hooks.delete(proc)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'runs the given block on each page load' do
|
27
|
+
browser.after_hooks.add { |browser| @output = browser.text }
|
17
28
|
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
18
29
|
|
19
30
|
expect(@output).to include('Dubito, ergo cogito, ergo sum')
|
20
31
|
ensure
|
21
|
-
browser.after_hooks.delete
|
32
|
+
browser.after_hooks.delete browser.after_hooks[0]
|
22
33
|
end
|
23
34
|
end
|
24
35
|
|
25
|
-
|
26
|
-
|
27
|
-
|
36
|
+
describe '#delete' do
|
37
|
+
it 'removes a previously added after_hook' do
|
38
|
+
after_hook = ->(browser) { @output = browser.text }
|
28
39
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#delete' do
|
36
|
-
it 'removes a previously added after_hook' do
|
37
|
-
after_hook = ->(browser) { @output = browser.text }
|
38
|
-
|
39
|
-
browser.after_hooks.add(after_hook)
|
40
|
-
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
41
|
-
expect(@output).to include('Dubito, ergo cogito, ergo sum')
|
40
|
+
browser.after_hooks.add(after_hook)
|
41
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
42
|
+
expect(@output).to include('Dubito, ergo cogito, ergo sum')
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
browser.after_hooks.delete(after_hook)
|
45
|
+
browser.goto(WatirSpec.url_for('definition_lists.html'))
|
46
|
+
expect(@output).not_to include('definition_lists')
|
47
|
+
end
|
46
48
|
end
|
47
|
-
end
|
48
49
|
|
49
|
-
|
50
|
-
|
50
|
+
describe '#run' do
|
51
|
+
before { @yield = nil }
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
after do
|
54
|
+
browser.after_hooks.delete @page_after_hook
|
55
|
+
end
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
it 'runs after_hooks after Browser#goto' do
|
58
|
+
@page_after_hook = proc { @yield = browser.title == 'The font element' }
|
59
|
+
browser.after_hooks.add @page_after_hook
|
60
|
+
browser.goto WatirSpec.url_for('font.html')
|
61
|
+
expect(@yield).to be true
|
62
|
+
end
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
it 'runs after_hooks after Browser#refresh' do
|
65
|
+
browser.goto WatirSpec.url_for('font.html')
|
66
|
+
@page_after_hook = proc do
|
67
|
+
@yield = browser.title == 'The font element'
|
68
|
+
end
|
69
|
+
browser.after_hooks.add @page_after_hook
|
70
|
+
browser.refresh
|
71
|
+
expect(@yield).to be true
|
67
72
|
end
|
68
|
-
browser.after_hooks.add @page_after_hook
|
69
|
-
browser.refresh
|
70
|
-
expect(@yield).to be true
|
71
|
-
end
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
it 'runs after_hooks after Element#click' do
|
75
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
76
|
+
@page_after_hook = proc do
|
77
|
+
browser.wait_until { |b| b.title == 'Forms with input elements' }
|
78
|
+
@yield = true
|
79
|
+
end
|
80
|
+
browser.after_hooks.add @page_after_hook
|
81
|
+
browser.link(index: 2).click
|
82
|
+
expect(@yield).to be true
|
78
83
|
end
|
79
|
-
browser.after_hooks.add @page_after_hook
|
80
|
-
browser.link(index: 2).click
|
81
|
-
expect(@yield).to be true
|
82
|
-
end
|
83
84
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
it 'runs after_hooks after Element#submit' do
|
86
|
+
browser.goto(WatirSpec.url_for('forms_with_input_elements.html'))
|
87
|
+
@page_after_hook = proc { @yield = browser.div(id: 'messages').text == 'submit' }
|
88
|
+
browser.after_hooks.add @page_after_hook
|
89
|
+
browser.form(id: 'new_user').submit
|
90
|
+
expect(@yield).to be true
|
91
|
+
end
|
91
92
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
93
|
+
it 'runs after_hooks after Element#double_click' do
|
94
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
95
|
+
@page_after_hook = proc { @yield = browser.title == 'Non-control elements' }
|
96
|
+
browser.after_hooks.add @page_after_hook
|
97
|
+
div = browser.div(id: 'html_test')
|
98
|
+
div.double_click
|
99
|
+
expect(@yield).to be true
|
100
|
+
end
|
100
101
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
102
|
+
it 'runs after_hooks after Element#right_click' do
|
103
|
+
browser.goto(WatirSpec.url_for('right_click.html'))
|
104
|
+
@page_after_hook = proc { @yield = browser.title == 'Right Click Test' }
|
105
|
+
browser.after_hooks.add @page_after_hook
|
106
|
+
div = browser.div(id: 'click')
|
107
|
+
div.right_click
|
108
|
+
expect(@yield).to be true
|
109
|
+
end
|
109
110
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
111
|
+
it 'runs after_hooks after Alert#ok' do
|
112
|
+
browser.goto(WatirSpec.url_for('alerts.html'))
|
113
|
+
@page_after_hook = proc { @yield = browser.title == 'Alerts' }
|
114
|
+
browser.after_hooks.add @page_after_hook
|
115
|
+
browser.after_hooks.without { browser.button(id: 'alert').click }
|
116
|
+
browser.alert.ok
|
117
|
+
expect(@yield).to be true
|
118
|
+
end
|
118
119
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
120
|
+
it 'runs after_hooks after Alert#close' do
|
121
|
+
browser.goto(WatirSpec.url_for('alerts.html'))
|
122
|
+
@page_after_hook = proc { @yield = browser.title == 'Alerts' }
|
123
|
+
browser.after_hooks.add @page_after_hook
|
124
|
+
browser.after_hooks.without { browser.button(id: 'alert').click }
|
125
|
+
browser.alert.close
|
126
|
+
expect(@yield).to be true
|
127
|
+
end
|
127
128
|
|
128
|
-
|
129
|
-
|
129
|
+
it 'does not run error checks with alert present' do
|
130
|
+
browser.goto WatirSpec.url_for('alerts.html')
|
130
131
|
|
131
|
-
|
132
|
-
|
132
|
+
@page_after_hook = proc { @yield = browser.title == 'Alerts' }
|
133
|
+
browser.after_hooks.add @page_after_hook
|
133
134
|
|
134
|
-
|
135
|
-
|
135
|
+
browser.button(id: 'alert').click
|
136
|
+
expect(@yield).to be_nil
|
136
137
|
|
137
|
-
|
138
|
-
|
139
|
-
|
138
|
+
browser.alert.ok
|
139
|
+
expect(@yield).to be true
|
140
|
+
end
|
140
141
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
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 { 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 } }.not_to raise_error
|
148
|
+
browser.alert.ok
|
149
|
+
end
|
149
150
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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 { 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 }.not_to raise_error
|
158
|
+
browser.alert.ok
|
159
|
+
end
|
159
160
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
161
|
+
it 'does not raise error when running error checks on closed window',
|
162
|
+
exclude: [{browser: :safari,
|
163
|
+
reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'},
|
164
|
+
{browser: :firefox,
|
165
|
+
platform: :windows,
|
166
|
+
reason: 'https://github.com/mozilla/geckodriver/issues/1847'},
|
167
|
+
{browser: :ie,
|
168
|
+
reason: 'IE and windows do not play well together'}] do
|
169
|
+
url = WatirSpec.url_for('window_switching.html')
|
170
|
+
@page_after_hook = proc { browser.url }
|
171
|
+
browser.after_hooks.add @page_after_hook
|
172
|
+
browser.goto url
|
173
|
+
browser.a(id: 'open').click
|
174
|
+
|
175
|
+
window = browser.window(title: 'closeable window')
|
176
|
+
window.use
|
177
|
+
expect { browser.a(id: 'close').click }.not_to raise_error
|
178
|
+
browser.original_window.use
|
179
|
+
end
|
178
180
|
end
|
179
|
-
end
|
180
181
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
182
|
+
describe '#length' do
|
183
|
+
it 'provides the number of after hooks' do
|
184
|
+
hook = proc { true }
|
185
|
+
begin
|
186
|
+
4.times { browser.after_hooks.add(hook) }
|
187
|
+
expect(browser.after_hooks.length).to eq 4
|
188
|
+
ensure
|
189
|
+
4.times { browser.after_hooks.delete(hook) }
|
190
|
+
end
|
189
191
|
end
|
190
192
|
end
|
191
|
-
end
|
192
193
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
194
|
+
describe '#[]' do
|
195
|
+
it 'returns the after hook at the provided index' do
|
196
|
+
hook1 = proc { true }
|
197
|
+
hook2 = proc { false }
|
198
|
+
browser.after_hooks.add(hook1)
|
199
|
+
browser.after_hooks.add(hook2)
|
200
|
+
expect(browser.after_hooks[1]).to eq hook2
|
201
|
+
end
|
200
202
|
end
|
201
203
|
end
|
202
204
|
end
|
@@ -2,84 +2,87 @@
|
|
2
2
|
|
3
3
|
require 'watirspec_helper'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
after do
|
11
|
-
browser.alert.ok if browser.alert.exists?
|
12
|
-
end
|
5
|
+
module Watir
|
6
|
+
describe Alert do
|
7
|
+
before do
|
8
|
+
browser.goto WatirSpec.url_for('alerts.html')
|
9
|
+
end
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
it 'raises exception after timing out' do
|
17
|
-
expect { browser.alert.text }.to wait_and_raise_unknown_object_exception
|
18
|
-
end
|
11
|
+
after do
|
12
|
+
browser.alert.ok if browser.alert.exists?
|
19
13
|
end
|
20
|
-
end
|
21
14
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
15
|
+
describe 'Waits' do
|
16
|
+
context 'when acting on an alert' do
|
17
|
+
it 'raises exception after timing out' do
|
18
|
+
expect { browser.alert.text }.to wait_and_raise_unknown_object_exception
|
19
|
+
end
|
27
20
|
end
|
28
21
|
end
|
29
22
|
|
30
|
-
describe '
|
31
|
-
|
32
|
-
|
23
|
+
describe 'alert' do
|
24
|
+
describe '#text' do
|
25
|
+
it 'returns text of alert' do
|
26
|
+
browser.button(id: 'alert').click
|
27
|
+
expect(browser.alert.text).to include('ok')
|
28
|
+
end
|
33
29
|
end
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
describe '#exists?' do
|
32
|
+
it 'returns false if alert is not present' do
|
33
|
+
expect(browser.alert).not_to exist
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns true if alert is present' do
|
37
|
+
browser.button(id: 'alert').click
|
38
|
+
browser.wait_until(timeout: 10) { browser.alert.exists? }
|
39
|
+
expect(browser.alert.exist?).to be true
|
40
|
+
end
|
38
41
|
end
|
39
|
-
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
describe '#ok' do
|
44
|
+
it 'closes alert' do
|
45
|
+
browser.button(id: 'alert').click
|
46
|
+
browser.alert.ok
|
47
|
+
expect(browser.alert).not_to exist
|
48
|
+
end
|
46
49
|
end
|
47
|
-
end
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
describe '#close' do
|
52
|
+
it 'closes alert' do
|
53
|
+
browser.button(id: 'alert').click
|
54
|
+
browser.alert.close
|
55
|
+
expect(browser.alert).not_to exist
|
56
|
+
end
|
54
57
|
end
|
55
58
|
end
|
56
|
-
end
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
describe 'confirm' do
|
61
|
+
describe '#ok' do
|
62
|
+
it 'accepts confirm' do
|
63
|
+
browser.button(id: 'confirm').click
|
64
|
+
browser.alert.ok
|
65
|
+
expect(browser.button(id: 'confirm').value).to eq 'true'
|
66
|
+
end
|
64
67
|
end
|
65
|
-
end
|
66
68
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
describe '#close' do
|
70
|
+
it 'cancels confirm' do
|
71
|
+
browser.button(id: 'confirm').click
|
72
|
+
browser.alert.close
|
73
|
+
expect(browser.button(id: 'confirm').value).to eq 'false'
|
74
|
+
end
|
72
75
|
end
|
73
76
|
end
|
74
|
-
end
|
75
77
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
describe 'prompt' do
|
79
|
+
describe '#set' do
|
80
|
+
it 'enters text to prompt' do
|
81
|
+
browser.button(id: 'prompt').click
|
82
|
+
browser.alert.set 'My Name'
|
83
|
+
browser.alert.ok
|
84
|
+
expect(browser.button(id: 'prompt').value).to eq 'My Name'
|
85
|
+
end
|
83
86
|
end
|
84
87
|
end
|
85
88
|
end
|