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::Capabilities do
|
@@ -49,25 +51,35 @@ describe Watir::Capabilities do
|
|
49
51
|
|
50
52
|
args = capabilities.to_args
|
51
53
|
expect(args.last[:http_client]).to be_a Watir::HttpClient
|
52
|
-
expect(args.last[:
|
54
|
+
expect(args.last[:options]).to be_a options_class(browser_symbol)
|
53
55
|
expect(args.last).not_to include(:service)
|
54
56
|
end
|
55
57
|
|
58
|
+
it 'errors with url and service' do
|
59
|
+
expect {
|
60
|
+
Watir::Capabilities.new(browser_symbol,
|
61
|
+
service: instance_double(Selenium::WebDriver::Service),
|
62
|
+
url: 'https://example.com/wd/hub/')
|
63
|
+
}.to raise_exception(ArgumentError, ':url and :service are not both allowed')
|
64
|
+
end
|
65
|
+
|
56
66
|
it 'just options has client & options but not capabilities or service' do
|
57
67
|
capabilities = Watir::Capabilities.new(options: options_class(browser_symbol).new)
|
58
68
|
|
59
69
|
args = capabilities.to_args
|
60
70
|
|
61
71
|
expect(args.last[:http_client]).to be_a Watir::HttpClient
|
62
|
-
expect(args.last[:
|
72
|
+
expect(args.last[:options]).to be_a options_class(browser_symbol)
|
63
73
|
expect(args.last).not_to include(:service)
|
64
74
|
end
|
65
75
|
|
66
76
|
it 'just capabilities has client & capabilities but not service' do
|
67
77
|
caps = Selenium::WebDriver::Remote::Capabilities.send(browser_symbol)
|
68
78
|
capabilities = Watir::Capabilities.new(capabilities: caps)
|
69
|
-
|
70
|
-
|
79
|
+
args = []
|
80
|
+
expect {
|
81
|
+
args = capabilities.to_args
|
82
|
+
}.to have_deprecated(:capabilities)
|
71
83
|
|
72
84
|
expect(args.last[:http_client]).to be_a Watir::HttpClient
|
73
85
|
expect(args.last[:capabilities]).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
@@ -84,7 +96,7 @@ describe Watir::Capabilities do
|
|
84
96
|
args = capabilities.to_args
|
85
97
|
expect(args.first).to eq browser_symbol
|
86
98
|
actual_service = args.last[:service]
|
87
|
-
expect(actual_service.instance_variable_get(
|
99
|
+
expect(actual_service.instance_variable_get(:@port)).to eq 1234
|
88
100
|
end
|
89
101
|
|
90
102
|
it 'builds service from a Hash' do
|
@@ -95,9 +107,9 @@ describe Watir::Capabilities do
|
|
95
107
|
args = capabilities.to_args
|
96
108
|
expect(args.first).to eq browser_symbol
|
97
109
|
actual_service = args.last[:service]
|
98
|
-
expect(actual_service.instance_variable_get(
|
99
|
-
expect(actual_service.instance_variable_get(
|
100
|
-
expect(actual_service.instance_variable_get(
|
110
|
+
expect(actual_service.instance_variable_get(:@port)).to eq 1234
|
111
|
+
expect(actual_service.instance_variable_get(:@executable_path)).to eq '/path/to/driver'
|
112
|
+
expect(actual_service.instance_variable_get(:@extra_args)).to include '--foo', '--bar'
|
101
113
|
end
|
102
114
|
|
103
115
|
it 'is a bad argument to service' do
|
@@ -127,8 +139,8 @@ describe Watir::Capabilities do
|
|
127
139
|
args = capabilities.to_args
|
128
140
|
actual_client = args.last[:http_client]
|
129
141
|
expect(actual_client).to be_a Watir::HttpClient
|
130
|
-
expect(actual_client.instance_variable_get(
|
131
|
-
expect(actual_client.instance_variable_get(
|
142
|
+
expect(actual_client.instance_variable_get(:@read_timeout)).to eq 10
|
143
|
+
expect(actual_client.instance_variable_get(:@open_timeout)).to eq 10
|
132
144
|
end
|
133
145
|
|
134
146
|
it 'raises an exception if :client receives something other than Hash or Client object' do
|
@@ -160,7 +172,7 @@ describe Watir::Capabilities do
|
|
160
172
|
script_timeout: 12}
|
161
173
|
capabilities = Watir::Capabilities.new(browser_symbol, options: options)
|
162
174
|
args = capabilities.to_args
|
163
|
-
actual_options = args.last[:
|
175
|
+
actual_options = args.last[:options]
|
164
176
|
expect(actual_options.timeouts[:page_load]).to eq 11_000
|
165
177
|
expect(actual_options.timeouts[:script]).to eq 12_000
|
166
178
|
end
|
@@ -168,10 +180,9 @@ describe Watir::Capabilities do
|
|
168
180
|
it 'has deprecated timeouts key with page load warning' do
|
169
181
|
options = {timeouts: {page_load: 11}}
|
170
182
|
capabilities = Watir::Capabilities.new(browser_symbol, options: options)
|
171
|
-
msg = 'timeouts has been deprecated, use page_load_timeout (in seconds) directly instead'
|
172
183
|
expect {
|
173
184
|
capabilities.to_args
|
174
|
-
}.to
|
185
|
+
}.to have_deprecated(:timeouts)
|
175
186
|
end
|
176
187
|
|
177
188
|
it 'has deprecated timeouts key with script warning' do
|
@@ -179,7 +190,7 @@ describe Watir::Capabilities do
|
|
179
190
|
expect {
|
180
191
|
capabilities = Watir::Capabilities.new(browser_symbol, options: options)
|
181
192
|
capabilities.to_args
|
182
|
-
}.to
|
193
|
+
}.to have_deprecated(:timeouts)
|
183
194
|
end
|
184
195
|
|
185
196
|
it 'does not allow implicit wait timeout in timeouts hash' do
|
@@ -194,14 +205,14 @@ describe Watir::Capabilities do
|
|
194
205
|
it 'unhandled prompt behavior defaults to ignore' do
|
195
206
|
capabilities = Watir::Capabilities.new(browser_symbol)
|
196
207
|
args = capabilities.to_args
|
197
|
-
actual_options = args.last[:
|
208
|
+
actual_options = args.last[:options]
|
198
209
|
expect(actual_options.unhandled_prompt_behavior).to eq :ignore
|
199
210
|
end
|
200
211
|
|
201
212
|
it 'unhandled prompt behavior can be overridden' do
|
202
213
|
capabilities = Watir::Capabilities.new(browser_symbol, options: {unhandled_prompt_behavior: :accept_and_notify})
|
203
214
|
args = capabilities.to_args
|
204
|
-
actual_options = args.last[:
|
215
|
+
actual_options = args.last[:options]
|
205
216
|
expect(actual_options.unhandled_prompt_behavior).to eq :accept_and_notify
|
206
217
|
end
|
207
218
|
|
@@ -210,7 +221,7 @@ describe Watir::Capabilities do
|
|
210
221
|
proxy = Selenium::WebDriver::Proxy.new(http: '127.0.0.1:8080', ssl: '127.0.0.1:443')
|
211
222
|
capabilities = Watir::Capabilities.new(browser_symbol, proxy: proxy)
|
212
223
|
args = capabilities.to_args
|
213
|
-
proxy = args.last[:
|
224
|
+
proxy = args.last[:options].proxy
|
214
225
|
|
215
226
|
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
216
227
|
expect(proxy.type).to eq(:manual)
|
@@ -222,7 +233,7 @@ describe Watir::Capabilities do
|
|
222
233
|
proxy = {http: '127.0.0.1:8080', ssl: '127.0.0.1:443'}
|
223
234
|
capabilities = Watir::Capabilities.new(browser_symbol, proxy: proxy)
|
224
235
|
args = capabilities.to_args
|
225
|
-
proxy = args.last[:
|
236
|
+
proxy = args.last[:options].proxy
|
226
237
|
|
227
238
|
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
228
239
|
expect(proxy.type).to eq(:manual)
|
@@ -237,7 +248,7 @@ describe Watir::Capabilities do
|
|
237
248
|
|
238
249
|
capabilities = Watir::Capabilities.new(browser_symbol, options: options, proxy: proxy)
|
239
250
|
args = capabilities.to_args
|
240
|
-
actual_options = args.last[:
|
251
|
+
actual_options = args.last[:options]
|
241
252
|
|
242
253
|
expect(actual_options.proxy).to be_a Selenium::WebDriver::Proxy
|
243
254
|
expect(actual_options.proxy.type).to eq(:manual)
|
@@ -277,7 +288,7 @@ describe Watir::Capabilities do
|
|
277
288
|
capabilities = Watir::Capabilities.new(url: 'http://example.com')
|
278
289
|
args = capabilities.to_args
|
279
290
|
expect(args.first).to eq :remote
|
280
|
-
actual_options = args.last[:
|
291
|
+
actual_options = args.last[:options]
|
281
292
|
expect(actual_options.browser_name).to eq 'chrome'
|
282
293
|
end
|
283
294
|
|
@@ -289,7 +300,7 @@ describe Watir::Capabilities do
|
|
289
300
|
expect(args.last[:url]).to eq 'https://example.com/wd/hub/'
|
290
301
|
expect(args.last[:http_client]).to be_a Watir::HttpClient
|
291
302
|
|
292
|
-
expect(args.last[:
|
303
|
+
expect(args.last[:options]).to be_a Selenium::WebDriver::Firefox::Options
|
293
304
|
expect(args.last).not_to include(:service)
|
294
305
|
end
|
295
306
|
|
@@ -310,7 +321,7 @@ describe Watir::Capabilities do
|
|
310
321
|
args = capabilities.to_args
|
311
322
|
expect(args.first).to eq :remote
|
312
323
|
expect(args.last[:http_client]).to eq client
|
313
|
-
actual_options = args.last[:
|
324
|
+
actual_options = args.last[:options]
|
314
325
|
expect(actual_options.browser_name).to eq 'chrome'
|
315
326
|
end
|
316
327
|
|
@@ -320,8 +331,8 @@ describe Watir::Capabilities do
|
|
320
331
|
http_client: {read_timeout: 30})
|
321
332
|
args = capabilities.to_args
|
322
333
|
expect(args.first).to eq :remote
|
323
|
-
expect(args.last[:http_client].instance_variable_get(
|
324
|
-
actual_options = args.last[:
|
334
|
+
expect(args.last[:http_client].instance_variable_get(:@read_timeout)).to eq 30
|
335
|
+
actual_options = args.last[:options]
|
325
336
|
expect(actual_options.browser_name).to eq 'chrome'
|
326
337
|
end
|
327
338
|
|
@@ -332,7 +343,7 @@ describe Watir::Capabilities do
|
|
332
343
|
proxy: proxy)
|
333
344
|
args = capabilities.to_args
|
334
345
|
expect(args.first).to eq :remote
|
335
|
-
proxy = args.last[:
|
346
|
+
proxy = args.last[:options].proxy
|
336
347
|
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
337
348
|
expect(proxy.type).to eq(:manual)
|
338
349
|
expect(proxy.http).to eq('127.0.0.1:8080')
|
@@ -346,7 +357,7 @@ describe Watir::Capabilities do
|
|
346
357
|
proxy: proxy)
|
347
358
|
args = capabilities.to_args
|
348
359
|
expect(args.first).to eq :remote
|
349
|
-
proxy = args.last[:
|
360
|
+
proxy = args.last[:options].proxy
|
350
361
|
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
351
362
|
expect(proxy.type).to eq(:manual)
|
352
363
|
expect(proxy.http).to eq('127.0.0.1:8080')
|
@@ -359,7 +370,7 @@ describe Watir::Capabilities do
|
|
359
370
|
options: Selenium::WebDriver::Chrome::Options.new(args: ['--foo']))
|
360
371
|
args = capabilities.to_args
|
361
372
|
expect(args.first).to eq :remote
|
362
|
-
actual_options = args.last[:
|
373
|
+
actual_options = args.last[:options]
|
363
374
|
expect(actual_options.browser_name).to eq 'chrome'
|
364
375
|
expect(actual_options.args).to include('--foo')
|
365
376
|
end
|
@@ -372,7 +383,7 @@ describe Watir::Capabilities do
|
|
372
383
|
args = capabilities.to_args
|
373
384
|
expect(args.first).to eq :remote
|
374
385
|
expect(args.last[:url]).to eq 'http://example.com'
|
375
|
-
actual_options = args.last[:
|
386
|
+
actual_options = args.last[:options]
|
376
387
|
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
377
388
|
expect(actual_options.prefs).to eq(foo: 'bar')
|
378
389
|
end
|
@@ -381,7 +392,11 @@ describe Watir::Capabilities do
|
|
381
392
|
caps = Watir::Capabilities.new(:chrome,
|
382
393
|
url: 'https://example.com/wd/hub',
|
383
394
|
capabilities: Selenium::WebDriver::Remote::Capabilities.chrome)
|
384
|
-
args =
|
395
|
+
args = []
|
396
|
+
expect {
|
397
|
+
args = caps.to_args
|
398
|
+
}.to have_deprecated(:capabilities)
|
399
|
+
|
385
400
|
expect(args.first).to eq :remote
|
386
401
|
actual_capabilities = args.last[:capabilities]
|
387
402
|
expect(actual_capabilities).to be_a(Selenium::WebDriver::Remote::Capabilities)
|
@@ -394,8 +409,11 @@ describe Watir::Capabilities do
|
|
394
409
|
url: 'https://example.com/wd/hub',
|
395
410
|
capabilities: Selenium::WebDriver::Remote::Capabilities.chrome,
|
396
411
|
http_client: client)
|
412
|
+
args = []
|
413
|
+
expect {
|
414
|
+
args = caps.to_args
|
415
|
+
}.to have_deprecated(:capabilities)
|
397
416
|
|
398
|
-
args = caps.to_args
|
399
417
|
expect(args.first).to eq :remote
|
400
418
|
expect(args.last[:http_client]).to eq client
|
401
419
|
actual_capabilities = args.last[:capabilities]
|
@@ -416,10 +434,10 @@ describe Watir::Capabilities do
|
|
416
434
|
args = caps.to_args
|
417
435
|
expect(args.first).to eq :remote
|
418
436
|
expect(args.last[:http_client]).to eq client
|
419
|
-
actual_options = args.last[:
|
437
|
+
actual_options = args.last[:options]
|
420
438
|
expect(actual_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
421
439
|
expect(actual_options.prefs).to eq(foo: 'bar')
|
422
|
-
proxy = args.last[:
|
440
|
+
proxy = args.last[:options].proxy
|
423
441
|
expect(proxy).to be_a Selenium::WebDriver::Proxy
|
424
442
|
expect(proxy.type).to eq(:manual)
|
425
443
|
expect(proxy.http).to eq('127.0.0.1:8080')
|
@@ -442,7 +460,7 @@ describe Watir::Capabilities do
|
|
442
460
|
headless: true,
|
443
461
|
url: 'http://example.com')
|
444
462
|
args = capabilities.to_args
|
445
|
-
actual_options = args.last[:
|
463
|
+
actual_options = args.last[:options]
|
446
464
|
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
447
465
|
end
|
448
466
|
|
@@ -452,22 +470,23 @@ describe Watir::Capabilities do
|
|
452
470
|
url: 'http://example.com')
|
453
471
|
args = capabilities.to_args
|
454
472
|
|
455
|
-
expect(args.last[:
|
473
|
+
expect(args.last[:options].args).to include '-headless'
|
456
474
|
end
|
457
475
|
|
458
476
|
it 'supports multiple vendor capabilities' do
|
459
|
-
sauce_options = {'sauce:options': {username: ENV
|
460
|
-
access_key: ENV
|
477
|
+
sauce_options = {'sauce:options': {username: ENV.fetch('SAUCE_USERNAME', nil),
|
478
|
+
access_key: ENV.fetch('SAUCE_ACCESS_KEY', nil)}}
|
461
479
|
other_options = {'other:options': {foo: 'bar'}}
|
462
480
|
|
463
481
|
capabilities = Watir::Capabilities.new(:chrome,
|
464
482
|
options: sauce_options.merge(other_options),
|
465
483
|
url: 'https://ondemand.us-west-1.saucelabs.com')
|
466
484
|
|
467
|
-
|
468
|
-
expect(
|
469
|
-
expect(
|
470
|
-
expect(
|
485
|
+
generated_options = capabilities.to_args.last[:options]
|
486
|
+
expect(generated_options).to be_a(Selenium::WebDriver::Chrome::Options)
|
487
|
+
expect(generated_options.unhandled_prompt_behavior).to eq :ignore
|
488
|
+
expect(generated_options.instance_variable_get(:@options)[:'sauce:options']).to eq sauce_options[:'sauce:options']
|
489
|
+
expect(generated_options.instance_variable_get(:@options)[:'other:options']).to eq other_options[:'other:options']
|
471
490
|
end
|
472
491
|
end
|
473
492
|
|
@@ -476,14 +495,14 @@ describe Watir::Capabilities do
|
|
476
495
|
capabilities = Watir::Capabilities.new
|
477
496
|
args = capabilities.to_args
|
478
497
|
expect(args.last[:http_client]).to be_a Watir::HttpClient
|
479
|
-
expect(args.last[:
|
498
|
+
expect(args.last[:options]).to be_a Selenium::WebDriver::Chrome::Options
|
480
499
|
expect(args.last).not_to include(:service)
|
481
500
|
end
|
482
501
|
|
483
502
|
it 'sets headless by creating options' do
|
484
503
|
capabilities = Watir::Capabilities.new(:chrome, headless: true)
|
485
504
|
args = capabilities.to_args
|
486
|
-
actual_options = args.last[:
|
505
|
+
actual_options = args.last[:options]
|
487
506
|
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
488
507
|
end
|
489
508
|
|
@@ -492,7 +511,7 @@ describe Watir::Capabilities do
|
|
492
511
|
options: Selenium::WebDriver::Chrome::Options.new,
|
493
512
|
headless: true)
|
494
513
|
args = capabilities.to_args
|
495
|
-
actual_options = args.last[:
|
514
|
+
actual_options = args.last[:options]
|
496
515
|
expect(actual_options.args).to include '--headless', '--disable-gpu'
|
497
516
|
end
|
498
517
|
|
@@ -502,7 +521,7 @@ describe Watir::Capabilities do
|
|
502
521
|
options: options,
|
503
522
|
headless: true)
|
504
523
|
args = capabilities.to_args
|
505
|
-
actual_options = args.last[:
|
524
|
+
actual_options = args.last[:options]
|
506
525
|
expect(actual_options.args).to include '--headless', '--disable-gpu', '--foo'
|
507
526
|
end
|
508
527
|
|
@@ -510,7 +529,7 @@ describe Watir::Capabilities do
|
|
510
529
|
options = {args: %w[--foo --bar]}
|
511
530
|
capabilities = Watir::Capabilities.new(:chrome, options: options)
|
512
531
|
args = capabilities.to_args
|
513
|
-
actual_options = args.last[:
|
532
|
+
actual_options = args.last[:options]
|
514
533
|
expect(actual_options).to be_a Selenium::WebDriver::Chrome::Options
|
515
534
|
expect(actual_options.args).to include '--foo', '--bar'
|
516
535
|
end
|
@@ -521,7 +540,7 @@ describe Watir::Capabilities do
|
|
521
540
|
capabilities = Watir::Capabilities.new(:chrome,
|
522
541
|
options: opts)
|
523
542
|
args = capabilities.to_args
|
524
|
-
actual_options = args.last[:
|
543
|
+
actual_options = args.last[:options]
|
525
544
|
expect(actual_options.page_load_strategy).to eq 'eager'
|
526
545
|
expect(actual_options.args).to include '--foo', '--bar'
|
527
546
|
end
|
@@ -534,7 +553,7 @@ describe Watir::Capabilities do
|
|
534
553
|
|
535
554
|
capabilities = Watir::Capabilities.new(:firefox, options: options)
|
536
555
|
|
537
|
-
actual_options = capabilities.to_args.last[:
|
556
|
+
actual_options = capabilities.to_args.last[:options]
|
538
557
|
expect(actual_options.args).to include '--foo'
|
539
558
|
expect(actual_options.profile).to eq profile
|
540
559
|
end
|
@@ -545,7 +564,7 @@ describe Watir::Capabilities do
|
|
545
564
|
|
546
565
|
capabilities = Watir::Capabilities.new(:firefox, options: options)
|
547
566
|
|
548
|
-
actual_options = capabilities.to_args.last[:
|
567
|
+
actual_options = capabilities.to_args.last[:options]
|
549
568
|
expect(actual_options.args).to include '--foo'
|
550
569
|
expect(actual_options.profile).to eq profile
|
551
570
|
end
|
@@ -553,7 +572,7 @@ describe Watir::Capabilities do
|
|
553
572
|
it 'sets headless by creating options' do
|
554
573
|
capabilities = Watir::Capabilities.new(:firefox, headless: true)
|
555
574
|
args = capabilities.to_args
|
556
|
-
actual_options = args.last[:
|
575
|
+
actual_options = args.last[:options]
|
557
576
|
expect(actual_options.args).to include '-headless'
|
558
577
|
end
|
559
578
|
|
@@ -562,7 +581,7 @@ describe Watir::Capabilities do
|
|
562
581
|
options: Selenium::WebDriver::Firefox::Options.new,
|
563
582
|
headless: true)
|
564
583
|
args = capabilities.to_args
|
565
|
-
actual_options = args.last[:
|
584
|
+
actual_options = args.last[:options]
|
566
585
|
expect(actual_options.args).to include '-headless'
|
567
586
|
end
|
568
587
|
|
@@ -572,7 +591,7 @@ describe Watir::Capabilities do
|
|
572
591
|
options: options,
|
573
592
|
headless: true)
|
574
593
|
args = capabilities.to_args
|
575
|
-
actual_options = args.last[:
|
594
|
+
actual_options = args.last[:options]
|
576
595
|
expect(actual_options.args).to include '-headless', '-foo'
|
577
596
|
end
|
578
597
|
|
@@ -580,7 +599,7 @@ describe Watir::Capabilities do
|
|
580
599
|
options = {args: %w[--foo --bar]}
|
581
600
|
capabilities = Watir::Capabilities.new(:firefox, options: options)
|
582
601
|
args = capabilities.to_args
|
583
|
-
actual_options = args.last[:
|
602
|
+
actual_options = args.last[:options]
|
584
603
|
expect(actual_options).to be_a Selenium::WebDriver::Firefox::Options
|
585
604
|
expect(actual_options.args).to include '--foo', '--bar'
|
586
605
|
end
|
@@ -591,7 +610,7 @@ describe Watir::Capabilities do
|
|
591
610
|
capabilities = Watir::Capabilities.new(:firefox,
|
592
611
|
options: opts)
|
593
612
|
args = capabilities.to_args
|
594
|
-
actual_options = args.last[:
|
613
|
+
actual_options = args.last[:options]
|
595
614
|
expect(actual_options.args).to include '--foo', '--bar'
|
596
615
|
expect(actual_options.page_load_strategy).to eq 'eager'
|
597
616
|
end
|
@@ -610,7 +629,7 @@ describe Watir::Capabilities do
|
|
610
629
|
options = {automatic_inspection: true}
|
611
630
|
capabilities = Watir::Capabilities.new(:safari, options: options)
|
612
631
|
args = capabilities.to_args
|
613
|
-
actual_options = args.last[:
|
632
|
+
actual_options = args.last[:options]
|
614
633
|
expect(actual_options).to be_a Selenium::WebDriver::Safari::Options
|
615
634
|
expect(actual_options.automatic_inspection).to eq true
|
616
635
|
end
|
@@ -621,7 +640,7 @@ describe Watir::Capabilities do
|
|
621
640
|
capabilities = Watir::Capabilities.new(:safari,
|
622
641
|
options: opts)
|
623
642
|
args = capabilities.to_args
|
624
|
-
actual_options = args.last[:
|
643
|
+
actual_options = args.last[:options]
|
625
644
|
expect(actual_options.automatic_inspection).to eq true
|
626
645
|
expect(actual_options.page_load_strategy).to eq 'eager'
|
627
646
|
end
|
@@ -632,7 +651,7 @@ describe Watir::Capabilities do
|
|
632
651
|
options = {args: %w[--foo --bar]}
|
633
652
|
capabilities = Watir::Capabilities.new(:ie, options: options)
|
634
653
|
args = capabilities.to_args
|
635
|
-
actual_options = args.last[:
|
654
|
+
actual_options = args.last[:options]
|
636
655
|
expect(actual_options).to be_a Selenium::WebDriver::IE::Options
|
637
656
|
expect(actual_options.args).to include '--foo', '--bar'
|
638
657
|
end
|
@@ -641,7 +660,7 @@ describe Watir::Capabilities do
|
|
641
660
|
options = {browser_attach_timeout: true}
|
642
661
|
capabilities = Watir::Capabilities.new(:ie, options: options)
|
643
662
|
args = capabilities.to_args
|
644
|
-
actual_options = args.last[:
|
663
|
+
actual_options = args.last[:options]
|
645
664
|
expect(actual_options).to be_a Selenium::WebDriver::IE::Options
|
646
665
|
expect(actual_options.options[:browser_attach_timeout]).to eq true
|
647
666
|
end
|
@@ -652,7 +671,7 @@ describe Watir::Capabilities do
|
|
652
671
|
capabilities = Watir::Capabilities.new(:ie,
|
653
672
|
options: opts)
|
654
673
|
args = capabilities.to_args
|
655
|
-
actual_options = args.last[:
|
674
|
+
actual_options = args.last[:options]
|
656
675
|
expect(actual_options.args).to include '--foo'
|
657
676
|
expect(actual_options.page_load_strategy).to eq 'eager'
|
658
677
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../unit_helper'
|
2
4
|
|
3
5
|
describe Watir::Locators::Element::Matcher do
|
@@ -182,16 +184,16 @@ describe Watir::Locators::Element::Matcher do
|
|
182
184
|
end
|
183
185
|
|
184
186
|
it 'by visibility true' do
|
185
|
-
elements = [wd_element(tag_name: 'div',
|
186
|
-
wd_element(tag_name: 'span',
|
187
|
+
elements = [wd_element(tag_name: 'div', displayed?: false),
|
188
|
+
wd_element(tag_name: 'span', displayed?: true)]
|
187
189
|
@values_to_match = {visible: true}
|
188
190
|
|
189
191
|
expect(matcher.match(elements, values_to_match, @filter)).to eq elements[1]
|
190
192
|
end
|
191
193
|
|
192
194
|
it 'by visibility false' do
|
193
|
-
elements = [wd_element(tag_name: 'div',
|
194
|
-
wd_element(tag_name: 'span',
|
195
|
+
elements = [wd_element(tag_name: 'div', displayed?: true),
|
196
|
+
wd_element(tag_name: 'span', displayed?: false)]
|
195
197
|
@values_to_match = {visible: false}
|
196
198
|
|
197
199
|
expect(matcher.match(elements, values_to_match, @filter)).to eq elements[1]
|
@@ -287,9 +289,9 @@ describe Watir::Locators::Element::Matcher do
|
|
287
289
|
end
|
288
290
|
|
289
291
|
it 'by visibility false' do
|
290
|
-
elements = [wd_element(
|
291
|
-
wd_element(
|
292
|
-
wd_element(
|
292
|
+
elements = [wd_element(displayed?: false),
|
293
|
+
wd_element(displayed?: true),
|
294
|
+
wd_element(displayed?: false)]
|
293
295
|
@values_to_match = {visible: false}
|
294
296
|
|
295
297
|
expect(matcher.match(elements, values_to_match, @filter)).to eq [elements[0], elements[2]]
|
@@ -416,7 +418,7 @@ describe Watir::Locators::Element::Matcher do
|
|
416
418
|
expect(matcher.match(elements, values_to_match, filter)).to eq nil
|
417
419
|
end
|
418
420
|
|
419
|
-
#
|
421
|
+
# NOTE: This will work after:text_regexp deprecation removed
|
420
422
|
it 'keeps element from being located' do
|
421
423
|
@values_to_match = {text: /some visible some hidden/}
|
422
424
|
allow(browser).to receive(:execute_script).and_return('all visible', 'some visible')
|