watir 7.1.0 → 7.2.0
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 +29 -16
- data/.github/workflows/edge.yml +19 -11
- data/.github/workflows/firefox.yml +28 -16
- data/.github/workflows/ie.yml +13 -7
- data/.github/workflows/safari.yml +22 -11
- data/.github/workflows/unit.yml +31 -23
- data/.rubocop.yml +14 -7
- data/.rubocop_todo.yml +0 -26
- data/CHANGES.md +16 -1
- data/Gemfile +6 -1
- data/README.md +15 -11
- data/Rakefile +9 -7
- data/lib/watir/adjacent.rb +3 -1
- data/lib/watir/after_hooks.rb +5 -3
- data/lib/watir/alert.rb +2 -0
- data/lib/watir/aliases.rb +2 -0
- data/lib/watir/attribute_helper.rb +4 -2
- data/lib/watir/browser.rb +10 -14
- data/lib/watir/capabilities.rb +56 -33
- data/lib/watir/cell_container.rb +2 -0
- data/lib/watir/container.rb +2 -0
- data/lib/watir/cookies.rb +5 -5
- data/lib/watir/element_collection.rb +3 -1
- data/lib/watir/elements/button.rb +2 -0
- data/lib/watir/elements/cell.rb +2 -0
- data/lib/watir/elements/checkbox.rb +2 -0
- data/lib/watir/elements/date_field.rb +2 -0
- data/lib/watir/elements/date_time_field.rb +2 -0
- data/lib/watir/elements/dlist.rb +3 -1
- data/lib/watir/elements/element.rb +29 -105
- data/lib/watir/elements/file_field.rb +2 -0
- data/lib/watir/elements/font.rb +2 -0
- data/lib/watir/elements/form.rb +2 -0
- data/lib/watir/elements/hidden.rb +2 -0
- data/lib/watir/elements/iframe.rb +2 -0
- data/lib/watir/elements/image.rb +2 -0
- data/lib/watir/elements/input.rb +2 -0
- data/lib/watir/elements/link.rb +2 -0
- data/lib/watir/elements/list.rb +2 -0
- data/lib/watir/elements/option.rb +2 -0
- data/lib/watir/elements/radio.rb +2 -0
- data/lib/watir/elements/row.rb +2 -0
- data/lib/watir/elements/select.rb +2 -0
- data/lib/watir/elements/table.rb +3 -1
- data/lib/watir/elements/table_cell.rb +2 -0
- data/lib/watir/elements/table_row.rb +2 -0
- data/lib/watir/elements/table_section.rb +2 -0
- data/lib/watir/elements/text_area.rb +2 -0
- data/lib/watir/elements/text_field.rb +2 -0
- data/lib/watir/exception.rb +2 -0
- data/lib/watir/extensions/nokogiri.rb +2 -0
- data/lib/watir/generator/base/generator.rb +2 -0
- data/lib/watir/generator/base/idl_sorter.rb +3 -1
- data/lib/watir/generator/base/spec_extractor.rb +6 -4
- data/lib/watir/generator/base/util.rb +2 -0
- data/lib/watir/generator/base/visitor.rb +5 -5
- data/lib/watir/generator/base.rb +2 -1
- data/lib/watir/generator/html/generator.rb +2 -0
- data/lib/watir/generator/html/spec_extractor.rb +2 -0
- data/lib/watir/generator/html/visitor.rb +2 -0
- data/lib/watir/generator/html.rb +2 -0
- data/lib/watir/generator/svg/generator.rb +2 -0
- data/lib/watir/generator/svg/spec_extractor.rb +2 -0
- data/lib/watir/generator/svg/visitor.rb +2 -0
- data/lib/watir/generator/svg.rb +2 -0
- data/lib/watir/generator.rb +2 -0
- data/lib/watir/has_window.rb +3 -1
- data/lib/watir/http_client.rb +2 -0
- data/lib/watir/js_execution.rb +2 -0
- data/lib/watir/js_snippets.rb +2 -0
- data/lib/watir/locators/anchor/selector_builder.rb +2 -0
- data/lib/watir/locators/button/matcher.rb +2 -0
- data/lib/watir/locators/button/selector_builder/xpath.rb +15 -19
- data/lib/watir/locators/button/selector_builder.rb +2 -0
- data/lib/watir/locators/cell/selector_builder/xpath.rb +2 -0
- data/lib/watir/locators/cell/selector_builder.rb +2 -0
- data/lib/watir/locators/element/locator.rb +2 -0
- data/lib/watir/locators/element/matcher.rb +2 -0
- data/lib/watir/locators/element/selector_builder/regexp_disassembler.rb +2 -0
- data/lib/watir/locators/element/selector_builder/xpath.rb +16 -15
- data/lib/watir/locators/element/selector_builder/xpath_support.rb +4 -2
- data/lib/watir/locators/element/selector_builder.rb +16 -6
- data/lib/watir/locators/option/matcher.rb +2 -0
- data/lib/watir/locators/option/selector_builder/xpath.rb +2 -0
- data/lib/watir/locators/option/selector_builder.rb +2 -0
- data/lib/watir/locators/row/selector_builder/xpath.rb +2 -0
- data/lib/watir/locators/row/selector_builder.rb +2 -0
- data/lib/watir/locators/text_area/selector_builder/xpath.rb +2 -0
- data/lib/watir/locators/text_area/selector_builder.rb +2 -0
- data/lib/watir/locators/text_field/matcher.rb +2 -0
- data/lib/watir/locators/text_field/selector_builder/xpath.rb +2 -0
- data/lib/watir/locators/text_field/selector_builder.rb +2 -0
- data/lib/watir/locators.rb +2 -0
- data/lib/watir/logger.rb +2 -0
- data/lib/watir/navigation.rb +3 -1
- data/lib/watir/radio_set.rb +2 -0
- data/lib/watir/row_container.rb +2 -0
- data/lib/watir/screenshot.rb +2 -0
- data/lib/watir/scroll.rb +27 -2
- data/lib/watir/search_context.rb +96 -0
- data/lib/watir/shadow_root.rb +60 -0
- data/lib/watir/user_editable.rb +3 -1
- data/lib/watir/version.rb +3 -1
- data/lib/watir/wait/timer.rb +3 -1
- data/lib/watir/wait.rb +5 -5
- data/lib/watir/window.rb +7 -3
- data/lib/watir/window_collection.rb +4 -1
- data/lib/watir.rb +4 -0
- data/lib/watirspec/guards.rb +2 -0
- data/lib/watirspec/implementation.rb +14 -10
- data/lib/watirspec/rake_tasks.rb +4 -4
- data/lib/watirspec/remote_server.rb +5 -3
- data/lib/watirspec/runner.rb +3 -1
- data/lib/watirspec/server/app.rb +2 -0
- data/lib/watirspec/server.rb +2 -0
- data/lib/watirspec.rb +7 -4
- data/spec/locator_spec_helper.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/capabilities_spec.rb +77 -58
- data/spec/unit/element_locator_spec.rb +2 -0
- data/spec/unit/match_elements/button_spec.rb +2 -0
- data/spec/unit/match_elements/element_spec.rb +10 -8
- data/spec/unit/match_elements/text_field_spec.rb +2 -0
- data/spec/unit/selector_builder/anchor_spec.rb +2 -0
- data/spec/unit/selector_builder/button_spec.rb +31 -28
- data/spec/unit/selector_builder/cell_spec.rb +3 -1
- data/spec/unit/selector_builder/element_spec.rb +61 -60
- data/spec/unit/selector_builder/row_spec.rb +21 -10
- data/spec/unit/selector_builder/text_field_spec.rb +29 -21
- data/spec/unit/selector_builder/textarea_spec.rb +2 -0
- data/spec/unit/unit_helper.rb +2 -0
- data/spec/unit/wait_spec.rb +2 -0
- data/spec/watirspec/adjacent_spec.rb +8 -6
- data/spec/watirspec/after_hooks_spec.rb +19 -21
- data/spec/watirspec/alert_spec.rb +2 -0
- data/spec/watirspec/attributes_spec.rb +2 -0
- data/spec/watirspec/browser_spec.rb +16 -12
- data/spec/watirspec/capabilities_spec.rb +569 -0
- data/spec/watirspec/cookies_spec.rb +4 -2
- data/spec/watirspec/drag_and_drop_spec.rb +2 -0
- data/spec/watirspec/element_hidden_spec.rb +2 -0
- data/spec/watirspec/elements/area_spec.rb +2 -0
- data/spec/watirspec/elements/areas_spec.rb +2 -0
- data/spec/watirspec/elements/button_spec.rb +2 -0
- data/spec/watirspec/elements/buttons_spec.rb +2 -0
- data/spec/watirspec/elements/checkbox_spec.rb +2 -0
- data/spec/watirspec/elements/checkboxes_spec.rb +2 -0
- data/spec/watirspec/elements/collections_spec.rb +5 -3
- data/spec/watirspec/elements/date_field_spec.rb +2 -0
- data/spec/watirspec/elements/date_fields_spec.rb +2 -0
- data/spec/watirspec/elements/date_time_field_spec.rb +2 -0
- data/spec/watirspec/elements/date_time_fields_spec.rb +2 -0
- data/spec/watirspec/elements/dd_spec.rb +2 -0
- data/spec/watirspec/elements/dds_spec.rb +2 -0
- data/spec/watirspec/elements/del_spec.rb +2 -0
- data/spec/watirspec/elements/dels_spec.rb +2 -0
- data/spec/watirspec/elements/div_spec.rb +2 -1
- data/spec/watirspec/elements/divs_spec.rb +2 -0
- data/spec/watirspec/elements/dl_spec.rb +6 -6
- data/spec/watirspec/elements/dls_spec.rb +2 -0
- data/spec/watirspec/elements/dt_spec.rb +2 -0
- data/spec/watirspec/elements/dts_spec.rb +2 -0
- data/spec/watirspec/elements/element_spec.rb +9 -1
- data/spec/watirspec/elements/elements_spec.rb +2 -0
- data/spec/watirspec/elements/em_spec.rb +2 -0
- data/spec/watirspec/elements/ems_spec.rb +2 -0
- data/spec/watirspec/elements/filefield_spec.rb +2 -0
- data/spec/watirspec/elements/filefields_spec.rb +2 -0
- data/spec/watirspec/elements/font_spec.rb +2 -0
- data/spec/watirspec/elements/form_spec.rb +2 -0
- data/spec/watirspec/elements/forms_spec.rb +2 -0
- data/spec/watirspec/elements/frame_spec.rb +2 -0
- data/spec/watirspec/elements/frames_spec.rb +2 -0
- data/spec/watirspec/elements/hidden_spec.rb +2 -0
- data/spec/watirspec/elements/hiddens_spec.rb +2 -0
- data/spec/watirspec/elements/hn_spec.rb +2 -0
- data/spec/watirspec/elements/hns_spec.rb +2 -0
- data/spec/watirspec/elements/iframe_spec.rb +3 -1
- data/spec/watirspec/elements/iframes_spec.rb +2 -0
- data/spec/watirspec/elements/image_spec.rb +2 -0
- data/spec/watirspec/elements/images_spec.rb +2 -0
- data/spec/watirspec/elements/input_spec.rb +2 -0
- data/spec/watirspec/elements/ins_spec.rb +2 -0
- data/spec/watirspec/elements/inses_spec.rb +2 -0
- data/spec/watirspec/elements/label_spec.rb +2 -0
- data/spec/watirspec/elements/labels_spec.rb +2 -0
- data/spec/watirspec/elements/li_spec.rb +2 -0
- data/spec/watirspec/elements/link_spec.rb +4 -4
- data/spec/watirspec/elements/links_spec.rb +2 -0
- data/spec/watirspec/elements/lis_spec.rb +2 -0
- data/spec/watirspec/elements/list_spec.rb +2 -0
- data/spec/watirspec/elements/map_spec.rb +2 -0
- data/spec/watirspec/elements/maps_spec.rb +2 -0
- data/spec/watirspec/elements/meta_spec.rb +2 -0
- data/spec/watirspec/elements/metas_spec.rb +2 -0
- data/spec/watirspec/elements/ol_spec.rb +2 -0
- data/spec/watirspec/elements/ols_spec.rb +2 -0
- data/spec/watirspec/elements/option_spec.rb +2 -0
- data/spec/watirspec/elements/p_spec.rb +2 -0
- data/spec/watirspec/elements/pre_spec.rb +2 -0
- data/spec/watirspec/elements/pres_spec.rb +2 -0
- data/spec/watirspec/elements/ps_spec.rb +2 -0
- data/spec/watirspec/elements/radio_spec.rb +2 -0
- data/spec/watirspec/elements/radios_spec.rb +2 -0
- data/spec/watirspec/elements/select_list_spec.rb +7 -1
- data/spec/watirspec/elements/select_lists_spec.rb +2 -0
- data/spec/watirspec/elements/span_spec.rb +2 -0
- data/spec/watirspec/elements/spans_spec.rb +2 -0
- data/spec/watirspec/elements/strong_spec.rb +2 -0
- data/spec/watirspec/elements/strongs_spec.rb +2 -0
- data/spec/watirspec/elements/table_nesting_spec.rb +2 -0
- data/spec/watirspec/elements/table_spec.rb +2 -0
- data/spec/watirspec/elements/tables_spec.rb +2 -0
- data/spec/watirspec/elements/tbody_spec.rb +2 -0
- data/spec/watirspec/elements/tbodys_spec.rb +2 -0
- data/spec/watirspec/elements/td_spec.rb +2 -0
- data/spec/watirspec/elements/tds_spec.rb +2 -0
- data/spec/watirspec/elements/text_field_spec.rb +2 -0
- data/spec/watirspec/elements/text_fields_spec.rb +2 -0
- data/spec/watirspec/elements/textarea_spec.rb +2 -0
- data/spec/watirspec/elements/textareas_spec.rb +2 -0
- data/spec/watirspec/elements/tfoot_spec.rb +2 -0
- data/spec/watirspec/elements/tfoots_spec.rb +2 -0
- data/spec/watirspec/elements/thead_spec.rb +2 -0
- data/spec/watirspec/elements/theads_spec.rb +2 -0
- data/spec/watirspec/elements/tr_spec.rb +2 -0
- data/spec/watirspec/elements/trs_spec.rb +2 -0
- data/spec/watirspec/elements/ul_spec.rb +2 -0
- data/spec/watirspec/elements/uls_spec.rb +2 -0
- data/spec/watirspec/html/child_frame.html +29 -0
- data/spec/watirspec/html/class_locator.html +2 -0
- data/spec/watirspec/html/scroll_nested.html +17 -0
- data/spec/watirspec/html/scroll_nested_offscreen.html +18 -0
- data/spec/watirspec/html/shadow_dom.html +28 -0
- data/spec/watirspec/radio_set_spec.rb +2 -0
- data/spec/watirspec/screenshot_spec.rb +4 -2
- data/spec/watirspec/scroll_spec.rb +75 -7
- data/spec/watirspec/shadow_root_spec.rb +103 -0
- data/spec/watirspec/special_chars_spec.rb +2 -0
- data/spec/watirspec/support/rspec_matchers.rb +35 -32
- data/spec/watirspec/user_editable_spec.rb +2 -0
- data/spec/watirspec/wait_spec.rb +2 -0
- data/spec/watirspec/window_switching_spec.rb +48 -38
- data/spec/watirspec_helper.rb +24 -18
- data/support/doctest_helper.rb +2 -0
- data/support/version_differ.rb +2 -0
- data/watir.gemspec +11 -8
- metadata +54 -215
- data/.github/actions/enable-safari/action.yml +0 -11
- data/.github/actions/install-chrome/action.yml +0 -12
- data/.github/actions/setup-linux/action.yml +0 -8
- data/lib/watir-webdriver.rb +0 -2
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../unit_helper'
|
2
4
|
|
3
5
|
describe Watir::Locators::TextField::SelectorBuilder do
|
@@ -7,18 +9,18 @@ describe Watir::Locators::TextField::SelectorBuilder do
|
|
7
9
|
let(:uppercase) { 'ABCDEFGHIJKLMNOPQRSTUVWXYZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞŸŽŠŒ' }
|
8
10
|
let(:lowercase) { 'abcdefghijklmnopqrstuvwxyzàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿžšœ' }
|
9
11
|
let(:negative_types) do
|
10
|
-
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('file','#{uppercase}','#{lowercase}') and "\
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('file','#{uppercase}','#{lowercase}') and " \
|
13
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('radio','#{uppercase}','#{lowercase}') and " \
|
14
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('checkbox','#{uppercase}','#{lowercase}') and " \
|
15
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('submit','#{uppercase}','#{lowercase}') and " \
|
16
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('reset','#{uppercase}','#{lowercase}') and " \
|
17
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('image','#{uppercase}','#{lowercase}') and " \
|
18
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('button','#{uppercase}','#{lowercase}') and " \
|
19
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('hidden','#{uppercase}','#{lowercase}') and " \
|
20
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('range','#{uppercase}','#{lowercase}') and " \
|
21
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('color','#{uppercase}','#{lowercase}') and " \
|
22
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('date','#{uppercase}','#{lowercase}') and " \
|
23
|
+
"translate(@type,'#{uppercase}','#{lowercase}')!=translate('datetime-local','#{uppercase}','#{lowercase}')"
|
22
24
|
end
|
23
25
|
|
24
26
|
describe '#build' do
|
@@ -33,7 +35,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
|
|
33
35
|
it 'specified text field type that is text' do
|
34
36
|
selector = {type: 'text'}
|
35
37
|
built = {xpath: ".//*[local-name()='input']" \
|
36
|
-
"[translate(@type,'#{uppercase}','#{lowercase}')=
|
38
|
+
"[translate(@type,'#{uppercase}','#{lowercase}')=" \
|
39
|
+
"translate('text','#{uppercase}','#{lowercase}')]"}
|
37
40
|
|
38
41
|
expect(selector_builder.build(selector)).to eq built
|
39
42
|
end
|
@@ -41,7 +44,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
|
|
41
44
|
it 'specified text field type that is not text' do
|
42
45
|
selector = {type: 'number'}
|
43
46
|
built = {xpath: ".//*[local-name()='input']" \
|
44
|
-
"[translate(@type,'#{uppercase}','#{lowercase}')=
|
47
|
+
"[translate(@type,'#{uppercase}','#{lowercase}')=" \
|
48
|
+
"translate('number','#{uppercase}','#{lowercase}')]"}
|
45
49
|
|
46
50
|
expect(selector_builder.build(selector)).to eq built
|
47
51
|
end
|
@@ -143,7 +147,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
|
|
143
147
|
it 'using String' do
|
144
148
|
selector = {label: 'First name'}
|
145
149
|
built = {xpath: ".//*[local-name()='input'][not(@type) or (#{negative_types})]" \
|
146
|
-
"[@id=//label[normalize-space()='First name']
|
150
|
+
"[@id=//label[normalize-space()='First name']" \
|
151
|
+
"/@for or parent::label[normalize-space()='First name']]"}
|
147
152
|
|
148
153
|
expect(selector_builder.build(selector)).to eq built
|
149
154
|
end
|
@@ -151,7 +156,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
|
|
151
156
|
it 'uses String with hidden text' do
|
152
157
|
selector = {label: 'With hidden text'}
|
153
158
|
built = {xpath: ".//*[local-name()='input'][not(@type) or (#{negative_types})]" \
|
154
|
-
"[@id=//label[normalize-space()='With hidden text']
|
159
|
+
"[@id=//label[normalize-space()='With hidden text']" \
|
160
|
+
"/@for or parent::label[normalize-space()='With hidden text']]"}
|
155
161
|
|
156
162
|
expect(selector_builder.build(selector)).to eq built
|
157
163
|
end
|
@@ -159,7 +165,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
|
|
159
165
|
it 'using simple Regexp' do
|
160
166
|
selector = {label: /First/}
|
161
167
|
built = {xpath: ".//*[local-name()='input'][not(@type) or (#{negative_types})]" \
|
162
|
-
|
168
|
+
'[@id=//label[contains(normalize-space(), "First")]' \
|
169
|
+
'/@for or parent::label[contains(normalize-space(), "First")]]'}
|
163
170
|
|
164
171
|
expect(selector_builder.build(selector)).to eq built
|
165
172
|
end
|
@@ -167,8 +174,9 @@ describe Watir::Locators::TextField::SelectorBuilder do
|
|
167
174
|
it 'using complex Regexp' do
|
168
175
|
selector = {label: /([qa])st? name/}
|
169
176
|
built = {xpath: ".//*[local-name()='input'][not(@type) or (#{negative_types})]" \
|
170
|
-
|
171
|
-
|
177
|
+
'[@id=//label[contains(normalize-space(), "s") and contains(normalize-space(), " name")]' \
|
178
|
+
'/@for or parent::label[contains(normalize-space(), "s") ' \
|
179
|
+
'and contains(normalize-space(), " name")]]',
|
172
180
|
label_element: /([qa])st? name/}
|
173
181
|
|
174
182
|
expect(selector_builder.build(selector)).to eq built
|
@@ -178,8 +186,8 @@ describe Watir::Locators::TextField::SelectorBuilder do
|
|
178
186
|
context 'with multiple locators' do
|
179
187
|
it 'locates using tag name, class, attributes and text' do
|
180
188
|
selector = {text: 'Developer', class: /c/, id: true}
|
181
|
-
built = {xpath: ".//*[local-name()='input'][contains(@class,
|
182
|
-
"[not(@type) or (#{negative_types})][@id]", text: 'Developer'}
|
189
|
+
built = {xpath: ".//*[local-name()='input'][contains(@class, \"c\")]" \
|
190
|
+
"[not(@type) or (#{negative_types})][@id]", text: 'Developer'}
|
183
191
|
|
184
192
|
expect(selector_builder.build(selector)).to eq built
|
185
193
|
end
|
data/spec/unit/unit_helper.rb
CHANGED
data/spec/unit/wait_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'watirspec_helper'
|
2
4
|
|
3
5
|
describe 'Adjacent Elements' do
|
@@ -53,13 +55,13 @@ describe 'Adjacent Elements' do
|
|
53
55
|
it 'accepts a tag name argument' do
|
54
56
|
siblings = browser.div(id: 'second_sibling').siblings(tag_name: 'div')
|
55
57
|
expect(siblings.size).to eq 3
|
56
|
-
expect(siblings.all?
|
58
|
+
expect(siblings.all?(Watir::Div)).to eq true
|
57
59
|
end
|
58
60
|
|
59
61
|
it 'accepts custom tag name argument' do
|
60
62
|
siblings = browser.div(id: 'regular_child').siblings(tag_name: 'childelement')
|
61
63
|
expect(siblings.size).to eq 3
|
62
|
-
expect(siblings.all?
|
64
|
+
expect(siblings.all?(Watir::HTMLElement)).to eq true
|
63
65
|
end
|
64
66
|
|
65
67
|
it 'accepts a class_name argument' do
|
@@ -67,7 +69,7 @@ describe 'Adjacent Elements' do
|
|
67
69
|
expect(siblings.first).to be_a Watir::Div
|
68
70
|
expect(siblings[0]).to be_a Watir::Div
|
69
71
|
expect(siblings.size).to eq 2
|
70
|
-
expect(siblings.all?
|
72
|
+
expect(siblings.all?(Watir::Div)).to eq true
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
@@ -234,19 +236,19 @@ describe 'Adjacent Elements' do
|
|
234
236
|
it 'accepts tag_name argument' do
|
235
237
|
children = browser.div(id: 'parent').children(tag_name: 'div')
|
236
238
|
expect(children.size).to eq 3
|
237
|
-
expect(children.all?
|
239
|
+
expect(children.all?(Watir::Div)).to eq true
|
238
240
|
end
|
239
241
|
|
240
242
|
it 'accepts custom tag_name argument' do
|
241
243
|
children = browser.element(id: 'custom_parent').children(tag_name: 'childelement')
|
242
244
|
expect(children.size).to eq 3
|
243
|
-
expect(children.all?
|
245
|
+
expect(children.all?(Watir::HTMLElement)).to eq true
|
244
246
|
end
|
245
247
|
|
246
248
|
it 'accepts a class_name argument' do
|
247
249
|
children = browser.div(id: 'parent').children(class_name: 'b')
|
248
250
|
expect(children.size).to eq 2
|
249
|
-
expect(children.all?
|
251
|
+
expect(children.all?(Watir::Div)).to eq true
|
250
252
|
end
|
251
253
|
end
|
252
254
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'watirspec_helper'
|
2
4
|
|
3
5
|
describe 'Browser::AfterHooks' do
|
@@ -7,45 +9,40 @@ describe 'Browser::AfterHooks' do
|
|
7
9
|
end
|
8
10
|
|
9
11
|
it 'runs the given proc on each page load' do
|
10
|
-
output =
|
11
|
-
proc = proc { |browser| output << browser.text }
|
12
|
+
proc = proc { |browser| @output = browser.text }
|
12
13
|
|
13
14
|
begin
|
14
15
|
browser.alert.dismiss if browser.alert.exists?
|
15
16
|
browser.after_hooks.add(proc)
|
16
17
|
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
17
18
|
|
18
|
-
expect(output).to include('Dubito, ergo cogito, ergo sum')
|
19
|
+
expect(@output).to include('Dubito, ergo cogito, ergo sum')
|
19
20
|
ensure
|
20
21
|
browser.after_hooks.delete(proc)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
25
|
it 'runs the given block on each page load' do
|
25
|
-
output =
|
26
|
-
|
27
|
-
browser.after_hooks.add { |browser| output << browser.text }
|
28
|
-
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
26
|
+
browser.after_hooks.add { |browser| @output = browser.text }
|
27
|
+
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
29
|
+
expect(@output).to include('Dubito, ergo cogito, ergo sum')
|
30
|
+
ensure
|
31
|
+
browser.after_hooks.delete browser.after_hooks[0]
|
34
32
|
end
|
35
33
|
end
|
36
34
|
|
37
35
|
describe '#delete' do
|
38
36
|
it 'removes a previously added after_hook' do
|
39
|
-
output =
|
40
|
-
after_hook = ->(browser) { output << browser.text }
|
37
|
+
after_hook = ->(browser) { @output = browser.text }
|
41
38
|
|
42
39
|
browser.after_hooks.add(after_hook)
|
43
40
|
browser.goto(WatirSpec.url_for('non_control_elements.html'))
|
44
|
-
expect(output).to include('Dubito, ergo cogito, ergo sum')
|
41
|
+
expect(@output).to include('Dubito, ergo cogito, ergo sum')
|
45
42
|
|
46
43
|
browser.after_hooks.delete(after_hook)
|
47
44
|
browser.goto(WatirSpec.url_for('definition_lists.html'))
|
48
|
-
expect(output).to_not include('definition_lists')
|
45
|
+
expect(@output).to_not include('definition_lists')
|
49
46
|
end
|
50
47
|
end
|
51
48
|
|
@@ -53,7 +50,6 @@ describe 'Browser::AfterHooks' do
|
|
53
50
|
before { @yield = nil }
|
54
51
|
|
55
52
|
after(:each) do
|
56
|
-
browser.original_window.use
|
57
53
|
browser.after_hooks.delete @page_after_hook
|
58
54
|
end
|
59
55
|
|
@@ -162,11 +158,13 @@ describe 'Browser::AfterHooks' do
|
|
162
158
|
end
|
163
159
|
|
164
160
|
it 'does not raise error when running error checks on closed window',
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
161
|
+
exclude: [{browser: :safari,
|
162
|
+
reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'},
|
163
|
+
{browser: :firefox,
|
164
|
+
platform: :windows,
|
165
|
+
reason: 'https://github.com/mozilla/geckodriver/issues/1847'},
|
166
|
+
{browser: :ie,
|
167
|
+
reason: 'IE and windows do not play well together'}] do
|
170
168
|
url = WatirSpec.url_for('window_switching.html')
|
171
169
|
@page_after_hook = proc { browser.url }
|
172
170
|
browser.after_hooks.add @page_after_hook
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'watirspec_helper'
|
2
4
|
|
3
5
|
describe 'Browser' do
|
@@ -9,7 +11,9 @@ describe 'Browser' do
|
|
9
11
|
|
10
12
|
it 'returns false if window is closed',
|
11
13
|
except: {browser: :safari,
|
12
|
-
reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'}
|
14
|
+
reason: 'Clicking an Element that Closes a Window is returning NoMatchingWindowFoundException'},
|
15
|
+
exclude: {browser: :ie,
|
16
|
+
reason: 'IE does not like switching windows'} do
|
13
17
|
browser.goto WatirSpec.url_for('window_switching.html')
|
14
18
|
browser.a(id: 'open').click
|
15
19
|
browser.windows.wait_until(size: 2)
|
@@ -182,7 +186,7 @@ describe 'Browser' do
|
|
182
186
|
@opts[:url] = url
|
183
187
|
@new_browser = WatirSpec.new_browser
|
184
188
|
|
185
|
-
server_url = @new_browser.driver.instance_variable_get(
|
189
|
+
server_url = @new_browser.driver.instance_variable_get(:@bridge).http.instance_variable_get(:@server_url)
|
186
190
|
expect(server_url).to eq URI.parse(url)
|
187
191
|
end
|
188
192
|
|
@@ -190,7 +194,7 @@ describe 'Browser' do
|
|
190
194
|
@opts.merge!(url: url, open_timeout: 44, read_timeout: 47)
|
191
195
|
@new_browser = WatirSpec.new_browser
|
192
196
|
|
193
|
-
http = @new_browser.driver.instance_variable_get(
|
197
|
+
http = @new_browser.driver.instance_variable_get(:@bridge).http
|
194
198
|
|
195
199
|
expect(http.open_timeout).to eq 44
|
196
200
|
expect(http.read_timeout).to eq 47
|
@@ -202,7 +206,7 @@ describe 'Browser' do
|
|
202
206
|
@opts[:http_client] = http_client
|
203
207
|
@new_browser = WatirSpec.new_browser
|
204
208
|
|
205
|
-
expect(@new_browser.driver.instance_variable_get(
|
209
|
+
expect(@new_browser.driver.instance_variable_get(:@bridge).http).to eq http_client
|
206
210
|
end
|
207
211
|
|
208
212
|
it 'accepts Remote::Capabilities instance as :desired_capabilities', only: {browser: :firefox} do
|
@@ -250,7 +254,7 @@ describe 'Browser' do
|
|
250
254
|
WatirSpec.implementation.browser_args = [:remote, opts]
|
251
255
|
msg = /You can pass values directly into Watir::Browser opt without needing to use :desired_capabilities/
|
252
256
|
expect { @new_browser = WatirSpec.new_browser }.to output(msg).to_stdout_from_any_process
|
253
|
-
server_url = @new_browser.driver.instance_variable_get(
|
257
|
+
server_url = @new_browser.driver.instance_variable_get(:@bridge).http.instance_variable_get(:@server_url)
|
254
258
|
expect(server_url).to eq URI.parse(url)
|
255
259
|
end
|
256
260
|
|
@@ -285,16 +289,16 @@ describe 'Browser' do
|
|
285
289
|
|
286
290
|
service = Selenium::WebDriver::Service.send(browser_name, port: '2314', args: ['foo'])
|
287
291
|
|
288
|
-
@opts
|
289
|
-
|
292
|
+
@opts[:service] = service
|
293
|
+
@opts[:listener] = LocalConfig::SelectorListener.new
|
290
294
|
|
291
295
|
@new_browser = WatirSpec.new_browser
|
292
296
|
|
293
|
-
bridge = @new_browser.wd.instance_variable_get(
|
297
|
+
bridge = @new_browser.wd.instance_variable_get(:@bridge)
|
294
298
|
expect(bridge).to be_a Selenium::WebDriver::Support::EventFiringBridge
|
295
|
-
service = @new_browser.wd.instance_variable_get(
|
296
|
-
expect(service.instance_variable_get(
|
297
|
-
expect(service.instance_variable_get(
|
299
|
+
service = @new_browser.wd.instance_variable_get(:@service)
|
300
|
+
expect(service.instance_variable_get(:@extra_args)).to eq ['foo']
|
301
|
+
expect(service.instance_variable_get(:@port)).to eq 2314
|
298
302
|
|
299
303
|
@new_browser.close
|
300
304
|
ensure
|
@@ -385,7 +389,7 @@ describe 'Browser' do
|
|
385
389
|
end
|
386
390
|
|
387
391
|
it 'returns correct Ruby objects' do
|
388
|
-
expect(browser.execute_script('return {a: 1, "b": 2}')).to eq
|
392
|
+
expect(browser.execute_script('return {a: 1, "b": 2}')).to eq({'a' => 1, 'b' => 2})
|
389
393
|
expect(browser.execute_script('return [1, 2, "3"]')).to match_array([1, 2, '3'])
|
390
394
|
expect(browser.execute_script('return 1.2 + 1.3')).to eq 2.5
|
391
395
|
expect(browser.execute_script('return 2 + 2')).to eq 4
|