watir 6.14.0 → 6.15.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/.rubocop.yml +24 -6
- data/CHANGES.md +10 -0
- data/Gemfile +0 -2
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/lib/watir.rb +2 -3
- data/lib/watir/adjacent.rb +2 -2
- data/lib/watir/alert.rb +5 -9
- data/lib/watir/attribute_helper.rb +2 -3
- data/lib/watir/browser.rb +5 -17
- data/lib/watir/capabilities.rb +11 -0
- data/lib/watir/cell_container.rb +2 -2
- data/lib/watir/container.rb +7 -8
- data/lib/watir/cookies.rb +2 -12
- data/lib/watir/element_collection.rb +2 -2
- data/lib/watir/elements/button.rb +2 -11
- data/lib/watir/elements/element.rb +43 -25
- data/lib/watir/elements/hidden.rb +1 -1
- data/lib/watir/elements/iframe.rb +7 -5
- data/lib/watir/elements/option.rb +2 -13
- data/lib/watir/elements/select.rb +6 -22
- data/lib/watir/elements/table.rb +2 -2
- data/lib/watir/exception.rb +1 -2
- data/lib/watir/generator/base/idl_sorter.rb +1 -1
- data/lib/watir/generator/base/spec_extractor.rb +2 -2
- data/lib/watir/generator/base/visitor.rb +1 -1
- data/lib/watir/generator/html/generator.rb +0 -1
- data/lib/watir/generator/html/spec_extractor.rb +1 -1
- data/lib/watir/generator/html/visitor.rb +1 -1
- data/lib/watir/generator/svg/spec_extractor.rb +1 -1
- data/lib/watir/generator/svg/visitor.rb +1 -1
- data/lib/watir/js_execution.rb +11 -0
- data/lib/watir/js_snippets.rb +1 -1
- data/lib/watir/js_snippets/elementObscured.js +14 -0
- data/lib/watir/js_snippets/selectedText.js +17 -0
- data/lib/watir/legacy_wait.rb +5 -5
- data/lib/watir/locators.rb +16 -5
- data/lib/watir/locators/anchor/selector_builder.rb +38 -0
- data/lib/watir/locators/button/locator.rb +14 -12
- data/lib/watir/locators/button/selector_builder.rb +0 -22
- data/lib/watir/locators/button/selector_builder/xpath.rb +67 -12
- data/lib/watir/locators/button/validator.rb +2 -1
- data/lib/watir/locators/cell/selector_builder.rb +0 -14
- data/lib/watir/locators/cell/selector_builder/xpath.rb +21 -0
- data/lib/watir/locators/element/locator.rb +60 -153
- data/lib/watir/locators/element/selector_builder.rb +103 -84
- data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +66 -0
- data/lib/watir/locators/element/selector_builder/xpath.rb +195 -82
- data/lib/watir/locators/element/selector_builder/xpath_support.rb +27 -0
- data/lib/watir/locators/element/validator.rb +2 -9
- data/lib/watir/locators/row/selector_builder.rb +5 -22
- data/lib/watir/locators/row/selector_builder/xpath.rb +53 -0
- data/lib/watir/locators/text_area/selector_builder.rb +1 -1
- data/lib/watir/locators/text_area/selector_builder/xpath.rb +19 -0
- data/lib/watir/locators/text_field/locator.rb +11 -8
- data/lib/watir/locators/text_field/selector_builder.rb +0 -23
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +33 -4
- data/lib/watir/locators/text_field/validator.rb +4 -4
- data/lib/watir/radio_set.rb +5 -5
- data/lib/watir/row_container.rb +2 -2
- data/lib/watir/user_editable.rb +2 -2
- data/lib/watir/version.rb +1 -1
- data/lib/watir/wait.rb +24 -37
- data/lib/watir/window.rb +11 -8
- data/lib/watirspec/remote_server.rb +3 -1
- data/spec/locator_spec_helper.rb +1 -1
- data/spec/spec_helper.rb +25 -1
- data/spec/unit/anchor_locator_spec.rb +68 -0
- data/spec/unit/capabilities_spec.rb +27 -0
- data/spec/unit/element_locator_spec.rb +184 -101
- data/spec/unit/logger_spec.rb +5 -0
- data/spec/watirspec/adjacent_spec.rb +34 -34
- data/spec/watirspec/after_hooks_spec.rb +78 -35
- data/spec/watirspec/alert_spec.rb +10 -0
- data/spec/watirspec/browser_spec.rb +27 -1
- data/spec/watirspec/element_hidden_spec.rb +6 -0
- data/spec/watirspec/elements/button_spec.rb +5 -11
- data/spec/watirspec/elements/buttons_spec.rb +1 -1
- data/spec/watirspec/elements/checkbox_spec.rb +2 -15
- data/spec/watirspec/elements/date_time_field_spec.rb +6 -1
- data/spec/watirspec/elements/dd_spec.rb +0 -17
- data/spec/watirspec/elements/del_spec.rb +0 -14
- data/spec/watirspec/elements/div_spec.rb +0 -18
- data/spec/watirspec/elements/dl_spec.rb +0 -17
- data/spec/watirspec/elements/dt_spec.rb +0 -17
- data/spec/watirspec/elements/element_spec.rb +177 -17
- data/spec/watirspec/elements/elements_spec.rb +7 -6
- data/spec/watirspec/elements/em_spec.rb +0 -13
- data/spec/watirspec/elements/filefield_spec.rb +0 -11
- data/spec/watirspec/elements/form_spec.rb +6 -0
- data/spec/watirspec/elements/hn_spec.rb +0 -14
- data/spec/watirspec/elements/iframe_spec.rb +15 -0
- data/spec/watirspec/elements/ins_spec.rb +0 -14
- data/spec/watirspec/elements/labels_spec.rb +1 -1
- data/spec/watirspec/elements/li_spec.rb +0 -14
- data/spec/watirspec/elements/link_spec.rb +22 -14
- data/spec/watirspec/elements/links_spec.rb +13 -0
- data/spec/watirspec/elements/list_spec.rb +15 -0
- data/spec/watirspec/elements/ol_spec.rb +0 -14
- data/spec/watirspec/elements/option_spec.rb +0 -10
- data/spec/watirspec/elements/p_spec.rb +0 -14
- data/spec/watirspec/elements/pre_spec.rb +0 -14
- data/spec/watirspec/elements/radio_spec.rb +0 -14
- data/spec/watirspec/elements/select_list_spec.rb +0 -10
- data/spec/watirspec/elements/span_spec.rb +4 -15
- data/spec/watirspec/elements/strong_spec.rb +4 -15
- data/spec/watirspec/elements/table_nesting_spec.rb +1 -1
- data/spec/watirspec/elements/table_spec.rb +7 -0
- data/spec/watirspec/elements/text_field_spec.rb +10 -2
- data/spec/watirspec/elements/text_fields_spec.rb +1 -1
- data/spec/watirspec/elements/tr_spec.rb +1 -1
- data/spec/watirspec/elements/ul_spec.rb +0 -14
- data/spec/watirspec/html/closeable.html +8 -0
- data/spec/watirspec/html/forms_with_input_elements.html +28 -23
- data/spec/watirspec/html/nested_elements.html +9 -9
- data/spec/watirspec/html/obscured.html +34 -0
- data/spec/watirspec/html/tables.html +13 -13
- data/spec/watirspec/radio_set_spec.rb +5 -0
- data/spec/watirspec/selector_builder/button_spec.rb +254 -0
- data/spec/watirspec/selector_builder/cell_spec.rb +93 -0
- data/spec/watirspec/selector_builder/element_spec.rb +639 -0
- data/spec/watirspec/selector_builder/row_spec.rb +150 -0
- data/spec/watirspec/selector_builder/text_spec.rb +170 -0
- data/spec/watirspec/support/rspec_matchers.rb +6 -1
- data/spec/watirspec/user_editable_spec.rb +4 -0
- data/spec/watirspec/wait_spec.rb +65 -14
- data/spec/watirspec/window_switching_spec.rb +54 -1
- data/spec/watirspec_helper.rb +2 -0
- data/watir.gemspec +7 -1
- metadata +86 -8
- data/lib/watir/locators/text_area/locator.rb +0 -13
- data/lib/watir/xpath_support.rb +0 -18
data/spec/unit/logger_spec.rb
CHANGED
@@ -24,6 +24,11 @@ module Watir
|
|
24
24
|
expect(Watir.logger.level).to eq(1)
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'allows to change level with integer' do
|
28
|
+
Watir.logger.level = 3
|
29
|
+
expect(Watir.logger.level).to eq(3)
|
30
|
+
end
|
31
|
+
|
27
32
|
it 'outputs to stdout by default' do
|
28
33
|
expect { Watir.logger.warn('message') }.to output(/WARN Watir message/).to_stdout_from_any_process
|
29
34
|
end
|
@@ -17,13 +17,13 @@ describe 'Adjacent Elements' do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'accepts tag_name argument' do
|
20
|
-
expect(browser.div(id: 'first_sibling').parent(tag_name:
|
21
|
-
expect(browser.div(id: 'first_sibling').parent(tag_name:
|
20
|
+
expect(browser.div(id: 'first_sibling').parent(tag_name: 'div').id).to eq 'parent'
|
21
|
+
expect(browser.div(id: 'first_sibling').parent(tag_name: 'div')).to be_a Watir::Div
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'accepts custom tag_name argument' do
|
25
|
-
expect(browser.div(id: 'regular_child').parent(tag_name:
|
26
|
-
expect(browser.div(id: 'regular_child').parent(tag_name:
|
25
|
+
expect(browser.div(id: 'regular_child').parent(tag_name: 'grandelement').id).to eq 'custom_grandparent'
|
26
|
+
expect(browser.div(id: 'regular_child').parent(tag_name: 'grandelement')).to be_a Watir::HTMLElement
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'accepts class_name argument' do
|
@@ -31,8 +31,8 @@ describe 'Adjacent Elements' do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'accepts index and tag_name arguments' do
|
34
|
-
expect(browser.div(id: 'first_sibling').parent(tag_name:
|
35
|
-
expect(browser.div(id: 'first_sibling').parent(tag_name:
|
34
|
+
expect(browser.div(id: 'first_sibling').parent(tag_name: 'div', index: 1).id).to eq 'grandparent'
|
35
|
+
expect(browser.div(id: 'first_sibling').parent(tag_name: 'div', index: 1)).to be_a Watir::Div
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'does not error when no parent element of an index exists' do
|
@@ -40,7 +40,7 @@ describe 'Adjacent Elements' do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'does not error when no parent element of a tag_name exists' do
|
43
|
-
expect(browser.div(id: 'first_sibling').parent(tag_name:
|
43
|
+
expect(browser.div(id: 'first_sibling').parent(tag_name: 'table')).to_not exist
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -51,13 +51,13 @@ describe 'Adjacent Elements' do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'accepts a tag name argument' do
|
54
|
-
siblings = browser.div(id: 'second_sibling').siblings(tag_name:
|
54
|
+
siblings = browser.div(id: 'second_sibling').siblings(tag_name: 'div')
|
55
55
|
expect(siblings.size).to eq 3
|
56
56
|
expect(siblings.all? { |sib| sib.is_a? Watir::Div }).to eq true
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'accepts custom tag name argument' do
|
60
|
-
siblings = browser.div(id: 'regular_child').siblings(tag_name:
|
60
|
+
siblings = browser.div(id: 'regular_child').siblings(tag_name: 'childelement')
|
61
61
|
expect(siblings.size).to eq 3
|
62
62
|
expect(siblings.all? { |sib| sib.is_a? Watir::HTMLElement }).to eq true
|
63
63
|
end
|
@@ -83,8 +83,8 @@ describe 'Adjacent Elements' do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'accepts tag_name argument' do
|
86
|
-
expect(browser.div(id: 'first_sibling').following_sibling(tag_name:
|
87
|
-
expect(browser.div(id: 'first_sibling').following_sibling(tag_name:
|
86
|
+
expect(browser.div(id: 'first_sibling').following_sibling(tag_name: 'div').id).to eq 'second_sibling'
|
87
|
+
expect(browser.div(id: 'first_sibling').following_sibling(tag_name: 'div')).to be_a Watir::Div
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'accepts class_name argument' do
|
@@ -92,16 +92,16 @@ describe 'Adjacent Elements' do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'accepts index and tag_name arguments' do
|
95
|
-
expect(browser.div(id: 'first_sibling').following_sibling(tag_name:
|
96
|
-
expect(browser.div(id: 'first_sibling').following_sibling(tag_name:
|
95
|
+
expect(browser.div(id: 'first_sibling').following_sibling(tag_name: 'div', index: 1).id).to eq 'third_sibling'
|
96
|
+
expect(browser.div(id: 'first_sibling').following_sibling(tag_name: 'div', index: 1)).to be_a Watir::Div
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'accepts text as Regexp' do
|
100
|
-
expect(browser.div(id: 'first_sibling').following_sibling(text: /
|
100
|
+
expect(browser.div(id: 'first_sibling').following_sibling(text: /T/).id).to eq 'third_sibling'
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'accepts text as String' do
|
104
|
-
expect(browser.div(id: 'first_sibling').following_sibling(text: '
|
104
|
+
expect(browser.div(id: 'first_sibling').following_sibling(text: 'Third').id).to eq 'third_sibling'
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'does not error when no next sibling of an index exists' do
|
@@ -109,7 +109,7 @@ describe 'Adjacent Elements' do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'does not error when no next sibling of a tag_name exists' do
|
112
|
-
expect(browser.div(id: 'first_sibling').following_sibling(tag_name:
|
112
|
+
expect(browser.div(id: 'first_sibling').following_sibling(tag_name: 'table')).to_not exist
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
@@ -120,8 +120,8 @@ describe 'Adjacent Elements' do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'accepts tag_name argument' do
|
123
|
-
expect(browser.div(id: 'second_sibling').following_siblings(tag_name:
|
124
|
-
expect(browser.div(id: 'second_sibling').following_siblings(tag_name:
|
123
|
+
expect(browser.div(id: 'second_sibling').following_siblings(tag_name: 'div').size).to eq 1
|
124
|
+
expect(browser.div(id: 'second_sibling').following_siblings(tag_name: 'div').first).to be_a Watir::Div
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'accepts class_name argument for single class' do
|
@@ -147,8 +147,8 @@ describe 'Adjacent Elements' do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
it 'accepts tag_name argument' do
|
150
|
-
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name:
|
151
|
-
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name:
|
150
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name: 'div').id).to eq 'second_sibling'
|
151
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name: 'div')).to be_a Watir::Div
|
152
152
|
end
|
153
153
|
|
154
154
|
it 'accepts class_name argument' do
|
@@ -156,8 +156,8 @@ describe 'Adjacent Elements' do
|
|
156
156
|
end
|
157
157
|
|
158
158
|
it 'accepts index and tag_name arguments' do
|
159
|
-
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name:
|
160
|
-
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name:
|
159
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name: 'div', index: 1).id).to eq 'first_sibling'
|
160
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name: 'div', index: 1)).to be_a Watir::Div
|
161
161
|
end
|
162
162
|
|
163
163
|
it 'does not error when no next sibling of an index exists' do
|
@@ -165,7 +165,7 @@ describe 'Adjacent Elements' do
|
|
165
165
|
end
|
166
166
|
|
167
167
|
it 'does not error when no next sibling of a tag_name exists' do
|
168
|
-
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name:
|
168
|
+
expect(browser.div(id: 'third_sibling').previous_sibling(tag_name: 'table')).to_not exist
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -176,8 +176,8 @@ describe 'Adjacent Elements' do
|
|
176
176
|
end
|
177
177
|
|
178
178
|
it 'accepts tag_name argument' do
|
179
|
-
expect(browser.div(id: 'second_sibling').previous_siblings(tag_name:
|
180
|
-
expect(browser.div(id: 'second_sibling').previous_siblings(tag_name:
|
179
|
+
expect(browser.div(id: 'second_sibling').previous_siblings(tag_name: 'div').size).to eq 1
|
180
|
+
expect(browser.div(id: 'second_sibling').previous_siblings(tag_name: 'div').first).to be_a Watir::Div
|
181
181
|
end
|
182
182
|
|
183
183
|
it 'accepts class_name argument' do
|
@@ -198,13 +198,13 @@ describe 'Adjacent Elements' do
|
|
198
198
|
end
|
199
199
|
|
200
200
|
it 'accepts tag_name argument' do
|
201
|
-
expect(browser.div(id: 'parent').child(tag_name:
|
202
|
-
expect(browser.div(id: 'parent').child(tag_name:
|
201
|
+
expect(browser.div(id: 'parent').child(tag_name: 'span').id).to eq 'between_siblings1'
|
202
|
+
expect(browser.div(id: 'parent').child(tag_name: 'span')).to be_a Watir::Span
|
203
203
|
end
|
204
204
|
|
205
205
|
it 'accepts custom tag_name argument' do
|
206
|
-
expect(browser.element(id: 'custom_parent').child(tag_name:
|
207
|
-
expect(browser.element(id: 'custom_parent').child(tag_name:
|
206
|
+
expect(browser.element(id: 'custom_parent').child(tag_name: 'childelement').id).to eq 'custom_child'
|
207
|
+
expect(browser.element(id: 'custom_parent').child(tag_name: 'childelement')).to be_a Watir::HTMLElement
|
208
208
|
end
|
209
209
|
|
210
210
|
it 'accepts class_name argument' do
|
@@ -212,8 +212,8 @@ describe 'Adjacent Elements' do
|
|
212
212
|
end
|
213
213
|
|
214
214
|
it 'accepts index and tag_name arguments' do
|
215
|
-
expect(browser.div(id: 'parent').child(tag_name:
|
216
|
-
expect(browser.div(id: 'parent').child(tag_name:
|
215
|
+
expect(browser.div(id: 'parent').child(tag_name: 'div', index: 1).id).to eq 'second_sibling'
|
216
|
+
expect(browser.div(id: 'parent').child(tag_name: 'div', index: 1)).to be_a Watir::Div
|
217
217
|
end
|
218
218
|
|
219
219
|
it 'does not error when no next sibling of an index exists' do
|
@@ -221,7 +221,7 @@ describe 'Adjacent Elements' do
|
|
221
221
|
end
|
222
222
|
|
223
223
|
it 'does not error when no next sibling of a tag_name exists' do
|
224
|
-
expect(browser.div(id: 'parent').child(tag_name:
|
224
|
+
expect(browser.div(id: 'parent').child(tag_name: 'table')).to_not exist
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
@@ -232,13 +232,13 @@ describe 'Adjacent Elements' do
|
|
232
232
|
end
|
233
233
|
|
234
234
|
it 'accepts tag_name argument' do
|
235
|
-
children = browser.div(id: 'parent').children(tag_name:
|
235
|
+
children = browser.div(id: 'parent').children(tag_name: 'div')
|
236
236
|
expect(children.size).to eq 3
|
237
237
|
expect(children.all? { |child| child.is_a? Watir::Div }).to eq true
|
238
238
|
end
|
239
239
|
|
240
240
|
it 'accepts custom tag_name argument' do
|
241
|
-
children = browser.element(id: 'custom_parent').children(tag_name:
|
241
|
+
children = browser.element(id: 'custom_parent').children(tag_name: 'childelement')
|
242
242
|
expect(children.size).to eq 3
|
243
243
|
expect(children.all? { |child| child.is_a? Watir::HTMLElement }).to eq true
|
244
244
|
end
|
@@ -11,6 +11,7 @@ describe 'Browser::AfterHooks' do
|
|
11
11
|
proc = proc { |browser| output << browser.text }
|
12
12
|
|
13
13
|
begin
|
14
|
+
browser.alert.dismiss if browser.alert.exists?
|
14
15
|
browser.after_hooks.add(proc)
|
15
16
|
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
16
17
|
|
@@ -19,6 +20,18 @@ describe 'Browser::AfterHooks' do
|
|
19
20
|
browser.after_hooks.delete(proc)
|
20
21
|
end
|
21
22
|
end
|
23
|
+
|
24
|
+
it 'runs the given block on each page load' do
|
25
|
+
output = ''
|
26
|
+
begin
|
27
|
+
browser.after_hooks.add { |browser| output << browser.text }
|
28
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
29
|
+
|
30
|
+
expect(output).to include('Dubito, ergo cogito, ergo sum')
|
31
|
+
ensure
|
32
|
+
browser.after_hooks.delete browser.after_hooks[0]
|
33
|
+
end
|
34
|
+
end
|
22
35
|
end
|
23
36
|
|
24
37
|
describe '#delete' do
|
@@ -125,58 +138,88 @@ describe 'Browser::AfterHooks' do
|
|
125
138
|
end
|
126
139
|
|
127
140
|
not_compliant_on :safari, :headless do
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
@page_after_hook = proc { @yield = browser.title == 'Alerts' }
|
132
|
-
browser.after_hooks.add @page_after_hook
|
141
|
+
bug 'chromedriver 2.43 https://bugs.chromium.org/p/chromedriver/issues/detail?id=2615', :chrome do
|
142
|
+
it 'does not run error checks with alert present' do
|
143
|
+
browser.goto WatirSpec.url_for('alerts.html')
|
133
144
|
|
134
|
-
|
135
|
-
|
145
|
+
@page_after_hook = proc { @yield = browser.title == 'Alerts' }
|
146
|
+
browser.after_hooks.add @page_after_hook
|
136
147
|
|
137
|
-
|
138
|
-
|
139
|
-
end
|
140
|
-
end
|
148
|
+
browser.button(id: 'alert').click
|
149
|
+
expect(@yield).to be_nil
|
141
150
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
@page_after_hook = proc { browser.url }
|
146
|
-
browser.after_hooks.add @page_after_hook
|
147
|
-
browser.goto url
|
148
|
-
expect { browser.after_hooks.without { browser.button(id: 'alert').click } }.to_not raise_error
|
149
|
-
browser.alert.ok
|
151
|
+
browser.alert.ok
|
152
|
+
expect(@yield).to eq true
|
153
|
+
end
|
150
154
|
end
|
151
155
|
end
|
152
156
|
|
153
157
|
not_compliant_on :headless do
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
158
|
+
bug 'chromedriver 2.43 https://bugs.chromium.org/p/chromedriver/issues/detail?id=2615', :chrome do
|
159
|
+
it 'does not raise error when running error checks using #after_hooks#without with alert present' do
|
160
|
+
url = WatirSpec.url_for('alerts.html')
|
161
|
+
@page_after_hook = proc { browser.url }
|
162
|
+
browser.after_hooks.add @page_after_hook
|
163
|
+
browser.goto url
|
164
|
+
expect { browser.after_hooks.without { browser.button(id: 'alert').click } }.to_not raise_error
|
165
|
+
browser.alert.ok
|
166
|
+
end
|
162
167
|
end
|
163
168
|
end
|
164
169
|
|
165
|
-
bug 'https://
|
170
|
+
bug 'chromedriver 2.43 https://bugs.chromium.org/p/chromedriver/issues/detail?id=2615', :chrome do
|
166
171
|
not_compliant_on :headless do
|
167
|
-
it 'does not raise error
|
168
|
-
url = WatirSpec.url_for('
|
172
|
+
it 'does not raise error if no error checks are defined with alert present' do
|
173
|
+
url = WatirSpec.url_for('alerts.html')
|
169
174
|
@page_after_hook = proc { browser.url }
|
170
175
|
browser.after_hooks.add @page_after_hook
|
171
176
|
browser.goto url
|
172
|
-
browser.
|
177
|
+
browser.after_hooks.delete @page_after_hook
|
178
|
+
expect { browser.button(id: 'alert').click }.to_not raise_error
|
179
|
+
browser.alert.ok
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
173
183
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
184
|
+
bug 'chromedriver 2.43 https://bugs.chromium.org/p/chromedriver/issues/detail?id=2615', :chrome do
|
185
|
+
bug 'https://bugzilla.mozilla.org/show_bug.cgi?id=1223277', :firefox do
|
186
|
+
not_compliant_on :headless do
|
187
|
+
it 'does not raise error when running error checks on closed window' do
|
188
|
+
url = WatirSpec.url_for('window_switching.html')
|
189
|
+
@page_after_hook = proc { browser.url }
|
190
|
+
browser.after_hooks.add @page_after_hook
|
191
|
+
browser.goto url
|
192
|
+
browser.a(id: 'open').click
|
193
|
+
|
194
|
+
window = browser.window(title: 'closeable window')
|
195
|
+
window.use
|
196
|
+
expect { browser.a(id: 'close').click }.to_not raise_error
|
197
|
+
browser.original_window.use
|
198
|
+
end
|
178
199
|
end
|
179
200
|
end
|
180
201
|
end
|
181
202
|
end
|
203
|
+
|
204
|
+
describe '#length' do
|
205
|
+
it 'provides the number of after hooks' do
|
206
|
+
hook = proc { true }
|
207
|
+
begin
|
208
|
+
4.times { browser.after_hooks.add(hook) }
|
209
|
+
expect(browser.after_hooks.length).to eq 4
|
210
|
+
ensure
|
211
|
+
4.times { browser.after_hooks.delete(hook) }
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
describe '#[]' do
|
217
|
+
it 'returns the after hook at the provided index' do
|
218
|
+
hook1 = proc { true }
|
219
|
+
hook2 = proc { false }
|
220
|
+
browser.after_hooks.add(hook1)
|
221
|
+
browser.after_hooks.add(hook2)
|
222
|
+
expect(browser.after_hooks[1]).to eq hook2
|
223
|
+
end
|
224
|
+
end
|
182
225
|
end
|
@@ -10,6 +10,16 @@ not_compliant_on :headless do
|
|
10
10
|
browser.alert.ok if browser.alert.exists?
|
11
11
|
end
|
12
12
|
|
13
|
+
not_compliant_on :not_relaxed_locate do
|
14
|
+
context 'Relaxed Waits' do
|
15
|
+
context 'when acting on an alert' do
|
16
|
+
it 'raises exception after timing out' do
|
17
|
+
expect { browser.alert.text }.to wait_and_raise_unknown_object_exception
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
13
23
|
context 'alert' do
|
14
24
|
describe '#text' do
|
15
25
|
it 'returns text of alert' do
|
@@ -381,7 +381,7 @@ describe 'Browser' do
|
|
381
381
|
browser.span(class: 'footer').click
|
382
382
|
expect(browser.span(class: 'footer').text).to include('Javascript')
|
383
383
|
browser.refresh
|
384
|
-
browser.span(class: 'footer').
|
384
|
+
browser.span(class: 'footer').wait_until(&:present?)
|
385
385
|
expect(browser.span(class: 'footer').text).to_not include('Javascript')
|
386
386
|
end
|
387
387
|
end
|
@@ -508,6 +508,32 @@ describe 'Browser' do
|
|
508
508
|
end
|
509
509
|
end
|
510
510
|
|
511
|
+
describe '#wait' do
|
512
|
+
# The only way to get engage this method is with page load strategy set to "none"
|
513
|
+
# Chrome will be blocking on document ready state because it does not yet support page load strategy
|
514
|
+
# This spec is both mocking out the response and demonstrating the necessary settings for it to be meaningful
|
515
|
+
not_compliant_on :chrome do
|
516
|
+
it 'waits for document ready state to be complete' do
|
517
|
+
@original = WatirSpec.implementation.clone
|
518
|
+
browser.close
|
519
|
+
@opts = WatirSpec.implementation.browser_args.last
|
520
|
+
|
521
|
+
@opts[:page_load_strategy] = 'none'
|
522
|
+
browser = WatirSpec.new_browser
|
523
|
+
|
524
|
+
start_time = Time.now
|
525
|
+
allow(browser).to receive(:ready_state) { Time.now < start_time + 3 ? 'loading' : 'complete' }
|
526
|
+
expect(browser.ready_state).to eq 'loading'
|
527
|
+
browser.wait(20)
|
528
|
+
expect(browser.ready_state).to eq 'complete'
|
529
|
+
|
530
|
+
browser.close
|
531
|
+
WatirSpec.implementation = @original.clone
|
532
|
+
$browser = WatirSpec.new_browser
|
533
|
+
end
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
511
537
|
describe '#inspect' do
|
512
538
|
it 'works even if browser is closed' do
|
513
539
|
expect(browser).to receive(:url).and_raise(Errno::ECONNREFUSED)
|
@@ -69,5 +69,11 @@ describe Watir::Locators::Element::Locator do
|
|
69
69
|
expect(elements.size).to eq 3
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
it 'raises exception when value is not Boolean' do
|
74
|
+
element = browser.body.element(visible: 'true')
|
75
|
+
msg = 'expected boolean, got "true":String'
|
76
|
+
expect { element.exists? }.to raise_exception(TypeError, msg)
|
77
|
+
end
|
72
78
|
end
|
73
79
|
end
|
@@ -94,16 +94,6 @@ describe 'Button' do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
# Attribute methods
|
97
|
-
describe '#class_name' do
|
98
|
-
it 'returns the class name of the button' do
|
99
|
-
expect(browser.button(name: 'new_user_image').class_name).to eq 'image'
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'returns an empty string if the button has no class name' do
|
103
|
-
expect(browser.button(name: 'new_user_submit').class_name).to eq ''
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
97
|
describe '#id' do
|
108
98
|
it 'returns the id if the button exists' do
|
109
99
|
expect(browser.button(index: 0).id).to eq 'new_user_submit'
|
@@ -190,13 +180,17 @@ describe 'Button' do
|
|
190
180
|
end
|
191
181
|
|
192
182
|
describe '#text' do
|
193
|
-
it 'returns the text of
|
183
|
+
it 'returns the text of an input button' do
|
194
184
|
expect(browser.button(index: 0).text).to eq 'Submit'
|
195
185
|
expect(browser.button(index: 1).text).to eq 'Reset'
|
196
186
|
expect(browser.button(index: 2).text).to eq 'Button'
|
197
187
|
expect(browser.button(index: 3).text).to eq 'Preview'
|
198
188
|
end
|
199
189
|
|
190
|
+
it 'returns the text of a button element' do
|
191
|
+
expect(browser.button(name: 'new_user_button_2').text).to eq 'Button 2'
|
192
|
+
end
|
193
|
+
|
200
194
|
it 'raises UnknownObjectException if the element does not exist' do
|
201
195
|
expect { browser.button(id: 'no_such_id').text }.to raise_unknown_object_exception
|
202
196
|
end
|