watir 6.19.1 → 7.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.github/actions/install-chrome/action.yml +1 -0
  3. data/.github/actions/setup-linux/action.yml +8 -0
  4. data/.github/workflows/tests.yml +100 -0
  5. data/CHANGES.md +7 -0
  6. data/README.md +1 -4
  7. data/Rakefile +1 -1
  8. data/lib/watir.rb +1 -45
  9. data/lib/watir/alert.rb +3 -8
  10. data/lib/watir/capabilities.rb +54 -230
  11. data/lib/watir/cell_container.rb +4 -4
  12. data/lib/watir/container.rb +4 -26
  13. data/lib/watir/elements/checkbox.rb +4 -4
  14. data/lib/watir/elements/date_field.rb +4 -4
  15. data/lib/watir/elements/date_time_field.rb +4 -4
  16. data/lib/watir/elements/element.rb +12 -49
  17. data/lib/watir/elements/file_field.rb +4 -4
  18. data/lib/watir/elements/font.rb +4 -4
  19. data/lib/watir/elements/hidden.rb +4 -4
  20. data/lib/watir/elements/html_elements.rb +444 -445
  21. data/lib/watir/elements/iframe.rb +4 -4
  22. data/lib/watir/elements/radio.rb +4 -4
  23. data/lib/watir/elements/select.rb +12 -78
  24. data/lib/watir/elements/svg_elements.rb +96 -96
  25. data/lib/watir/elements/text_field.rb +4 -4
  26. data/lib/watir/generator/base/generator.rb +4 -4
  27. data/lib/watir/generator/base/visitor.rb +0 -29
  28. data/lib/watir/generator/html/generator.rb +2 -1
  29. data/lib/watir/has_window.rb +4 -4
  30. data/lib/watir/http_client.rb +0 -8
  31. data/lib/watir/locators.rb +1 -5
  32. data/lib/watir/locators/button/matcher.rb +0 -23
  33. data/lib/watir/locators/button/selector_builder/xpath.rb +4 -15
  34. data/lib/watir/locators/element/matcher.rb +4 -19
  35. data/lib/watir/locators/element/selector_builder.rb +2 -37
  36. data/lib/watir/locators/element/selector_builder/xpath.rb +26 -41
  37. data/lib/watir/radio_set.rb +2 -2
  38. data/lib/watir/row_container.rb +4 -4
  39. data/lib/watir/version.rb +1 -1
  40. data/lib/watir/wait.rb +4 -74
  41. data/lib/watir/window.rb +6 -22
  42. data/lib/watir/window_collection.rb +5 -49
  43. data/lib/watirspec/implementation.rb +4 -0
  44. data/spec/spec_helper.rb +2 -7
  45. data/spec/unit/capabilities_spec.rb +196 -929
  46. data/spec/unit/match_elements/button_spec.rb +0 -13
  47. data/spec/unit/match_elements/element_spec.rb +38 -47
  48. data/spec/unit/match_elements/text_field_spec.rb +6 -6
  49. data/spec/unit/selector_builder/element_spec.rb +6 -23
  50. data/spec/unit/selector_builder/text_field_spec.rb +6 -7
  51. data/spec/watirspec/alert_spec.rb +4 -21
  52. data/spec/watirspec/browser_spec.rb +2 -2
  53. data/spec/watirspec/cookies_spec.rb +1 -1
  54. data/spec/watirspec/elements/button_spec.rb +0 -10
  55. data/spec/watirspec/elements/checkbox_spec.rb +10 -22
  56. data/spec/watirspec/elements/div_spec.rb +4 -34
  57. data/spec/watirspec/elements/divs_spec.rb +2 -2
  58. data/spec/watirspec/elements/element_spec.rb +38 -84
  59. data/spec/watirspec/elements/form_spec.rb +2 -4
  60. data/spec/watirspec/elements/links_spec.rb +4 -4
  61. data/spec/watirspec/elements/select_list_spec.rb +7 -108
  62. data/spec/watirspec/elements/span_spec.rb +2 -2
  63. data/spec/watirspec/elements/spans_spec.rb +1 -1
  64. data/spec/watirspec/elements/strong_spec.rb +1 -1
  65. data/spec/watirspec/html/non_control_elements.html +8 -3
  66. data/spec/watirspec/support/rspec_matchers.rb +1 -32
  67. data/spec/watirspec/window_switching_spec.rb +2 -49
  68. data/spec/watirspec_helper.rb +6 -1
  69. data/watir.gemspec +3 -4
  70. metadata +11 -32
  71. data/.github/workflows/linux.yml +0 -61
  72. data/.github/workflows/mac.yml +0 -55
  73. data/.github/workflows/unit.yml +0 -37
  74. data/.github/workflows/windows.yml +0 -39
  75. data/lib/watir/legacy_wait.rb +0 -123
  76. data/spec/unit/container_spec.rb +0 -35
  77. data/spec/watirspec/legacy_wait_spec.rb +0 -216
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c714ef62b6caccbf6f2885fd9ea9ece26d42c9b64f64642dadd445e35029da0c
4
- data.tar.gz: 2621db569beaa32c36577da613a0c27e16a64ca45e286a37e1cd000c3bf46db1
3
+ metadata.gz: 994057876b1f2ad97972dfe3a43f139cf761aefabcacbc7ab1d2bc659693e70e
4
+ data.tar.gz: d0bcac18f0cfe6d9d2a0258bb57a8e2e9f0804feda5eeaf8e5d840fd859de3c4
5
5
  SHA512:
6
- metadata.gz: 510bf92bb5212caec7334540076448f43bf13e4fcef510a36c78188718a1e744094b7cfe6dad3b713f51a2cf36f9ad22d5dfbf5983406fdb0bddcf75fb9a3fff
7
- data.tar.gz: 634cff1ed0f60d0d88f6596b377933b0ec6eda95dae9fd554352e4bb6c55ef2f8f7b791fd0b2abc8bcc39d3bc4e4a4f52429c7db6efae533fb1d8f0e45159159
6
+ metadata.gz: b652878ab0a6b4365e3226a664945a86c96f8f94c6b0cd4744c0809a66d8fb49ff37951726699df217856d413d4104778164218ca365a1481ec6ab1212c2f12e
7
+ data.tar.gz: f6f5f093a6072f1456055853d2b93ce994b978897668eb3348ee6fe70fa872eea681c97481d254830f5d028cce0029bb9e45a5dd25d50d785a6e144592d429a2
@@ -1,4 +1,5 @@
1
1
  name: 'Install Chrome'
2
+ description: 'Install Chrome Stable'
2
3
  runs:
3
4
  using: "composite"
4
5
  steps:
@@ -0,0 +1,8 @@
1
+ name: 'Setup Linux'
2
+ description: 'Run Linux in Virtual Desktop'
3
+ runs:
4
+ using: "composite"
5
+ steps:
6
+ - shell: bash
7
+ run: |
8
+ Xvfb :99 &
@@ -0,0 +1,100 @@
1
+ name: All Tests
2
+
3
+ on:
4
+ - push
5
+ - pull_request
6
+
7
+ jobs:
8
+ documentation-test:
9
+ name: Yard Doctest
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6
16
+ - run: bundle install
17
+ - uses: ./.github/actions/install-chrome
18
+ - uses: ./.github/actions/setup-linux
19
+ - run: |
20
+ bundle exec rake yard:doctest
21
+
22
+ unit-test:
23
+ name: Unit Tests
24
+ runs-on: ubuntu-latest
25
+ strategy:
26
+ fail-fast: false
27
+ matrix:
28
+ ruby: ['2.5', '2.6', '2.7', '3.0']
29
+ steps:
30
+ - uses: actions/checkout@v2
31
+ - uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby }}
34
+ - run: bundle install
35
+ - uses: ./.github/actions/install-chrome
36
+ - uses: ./.github/actions/setup-linux
37
+ - run: |
38
+ bundle exec rake spec:unit
39
+ env:
40
+ DISPLAY: :99
41
+
42
+ linter-test:
43
+ name: Rubocop Tests
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - uses: actions/checkout@v2
47
+ - uses: ruby/setup-ruby@v1
48
+ with:
49
+ ruby-version: 2.6
50
+ - run: bundle install
51
+ - run: bundle exec rubocop
52
+
53
+ local-tests:
54
+ name: Local Tests
55
+ runs-on: ${{ matrix.os }}
56
+ strategy:
57
+ fail-fast: false
58
+ matrix:
59
+ os: [ubuntu-latest, macos-latest, windows-latest]
60
+ ruby: [ 2.6, 3.0 ]
61
+ task: [ chrome, firefox, edge ]
62
+ include:
63
+ - os: 'macos-latest'
64
+ task: 'safari'
65
+ ruby: 2.6
66
+ - os: 'macos-latest'
67
+ task: 'safari'
68
+ ruby: 3.0
69
+ # - os: 'windows-latest'
70
+ # task: 'ie'
71
+ exclude:
72
+ - os: 'ubuntu-latest'
73
+ task: 'edge'
74
+ steps:
75
+ - uses: actions/checkout@v2
76
+ - uses: ./.github/actions/install-chrome
77
+ if: |
78
+ matrix.task == 'chrome' &&
79
+ matrix.os == 'ubuntu-latest'
80
+ - uses: ./.github/actions/setup-linux
81
+ if: matrix.os == 'ubuntu-latest'
82
+ - uses: browser-actions/setup-firefox@latest
83
+ with:
84
+ firefox-version: '86.0'
85
+ if: matrix.task == 'firefox'
86
+ - uses: ./.github/actions/enable-safari
87
+ if: matrix.task == 'safari'
88
+ - run: |
89
+ echo "COVERAGE=true" >> $GITHUB_ENV
90
+ if: |
91
+ matrix.os == 'ubuntu-latest' ||
92
+ matrix.os == 'macos-latest'
93
+ - uses: ruby/setup-ruby@v1
94
+ with:
95
+ ruby-version: ${{ matrix.ruby }}
96
+ - run: bundle install
97
+ - run: |
98
+ bundle exec rake spec:${{ matrix.task }}
99
+ env:
100
+ DISPLAY: :99
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ ### 7.0.0.beta1 (2021-03-18)
2
+
3
+ * Requires Selenium 4
4
+ * Supports Ruby 3
5
+ * Add support for Microsoft Edge Chromium
6
+ * Remove support for all deprecated functionality
7
+
1
8
  ### 6.19.1 (2021-03-17)
2
9
 
3
10
  * Fix bug preventing using Selenium 4
data/README.md CHANGED
@@ -3,10 +3,7 @@
3
3
  Watir Powered By Selenium!
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/watir.svg)](http://badge.fury.io/rb/watir)
6
- [![Unit Tests](https://github.com/watir/watir/workflows/Unit%20Tests/badge.svg)](https://github.com/watir/watir/actions?query=workflow%3A%22Unit+Tests%22)
7
- [![Mac Tests](https://github.com/watir/watir/workflows/Mac%20Tests/badge.svg)](https://github.com/watir/watir/actions?query=workflow%3A%22Mac+Tests%22)
8
- [![Windows Tests](https://github.com/watir/watir/workflows/Windows%20Tests/badge.svg)](https://github.com/watir/watir/actions?query=workflow%3A%22Windows+Tests%22)
9
- [![Linux Tests](https://github.com/watir/watir/workflows/Linux%20Tests/badge.svg)](https://github.com/watir/watir/actions?query=workflow%3A%22Linux+Tests%22)
6
+ [![All Tests](https://github.com/watir/watir/actions/workflows/tests.yml/badge.svg)](https://github.com/watir/watir/actions/workflows/tests.yml)
10
7
  [![Code Climate](https://codeclimate.com/github/watir/watir.svg)](https://codeclimate.com/github/watir/watir)
11
8
  [![Coverage Status](https://coveralls.io/repos/github/watir/watir/badge.svg?branch=main)](https://coveralls.io/github/watir/watir?branch=main)
12
9
 
data/Rakefile CHANGED
@@ -25,7 +25,7 @@ end
25
25
 
26
26
  {
27
27
  html: 'https://www.w3.org/TR/html52/single-page.html',
28
- svg: 'http://www.w3.org/TR/SVG2/single-page.html'
28
+ svg: 'https://www.w3.org/TR/2018/CR-SVG2-20180807/single-page.html'
29
29
  }.each do |type, spec_uri|
30
30
  namespace type do
31
31
  spec_path = "support/#{type}.html"
data/lib/watir.rb CHANGED
@@ -2,7 +2,6 @@ require 'selenium-webdriver'
2
2
  require 'time'
3
3
 
4
4
  require 'watir/scroll'
5
- require 'watir/legacy_wait'
6
5
  require 'watir/wait'
7
6
  require 'watir/exception'
8
7
  require 'watir/window'
@@ -24,51 +23,8 @@ require 'watir/logger'
24
23
  require 'watir/version'
25
24
 
26
25
  module Watir
27
- @relaxed_locate = true
28
-
29
26
  class << self
30
- attr_writer :relaxed_locate, :always_locate, :default_timeout, :prefer_css
31
-
32
- #
33
- # Whether or not Watir should wait for an element to be found or present
34
- # before taking an action.
35
- # Defaults to true.
36
- #
37
-
38
- def relaxed_locate?
39
- @relaxed_locate
40
- end
41
-
42
- #
43
- # Whether or not Watir should re-locate a stale Element on use.
44
- #
45
-
46
- def always_locate?
47
- always_locate_message
48
- true
49
- end
50
-
51
- def always_locate_message
52
- msg = 'Watir#always_locate'
53
- repl_msg = 'Element#stale? or Element#wait_until(&:stale?) if needed for flow control'
54
- Watir.logger.deprecate msg, repl_msg, ids: [:always_locate]
55
- end
56
-
57
- #
58
- # Whether or not Watir should prefer CSS when translating the Watir selector to Selenium.
59
- #
60
-
61
- def prefer_css?
62
- prefer_css_message
63
- false
64
- end
65
-
66
- def prefer_css_message
67
- msg = 'Watir#prefer_css'
68
- repl_msg = 'watir_css gem - https://github.com/watir/watir_css'
69
-
70
- Watir.logger.deprecate msg, repl_msg, ids: [:prefer_css]
71
- end
27
+ attr_writer :default_timeout
72
28
 
73
29
  #
74
30
  # Default wait time for wait methods.
data/lib/watir/alert.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  module Watir
2
2
  class Alert
3
- include EventuallyPresent
4
3
  include Waitable
5
4
  include Exception
6
5
 
@@ -104,13 +103,9 @@ module Watir
104
103
  end
105
104
 
106
105
  def wait_for_exists
107
- return assert_exists unless Watir.relaxed_locate?
108
-
109
- begin
110
- wait_until(message: 'waiting for alert', &:exists?)
111
- rescue Wait::TimeoutError
112
- raise UnknownObjectException, 'unable to locate alert'
113
- end
106
+ wait_until(message: 'waiting for alert', &:exists?)
107
+ rescue Wait::TimeoutError
108
+ raise UnknownObjectException, 'unable to locate alert'
114
109
  end
115
110
  end # Alert
116
111
  end # Watir
@@ -11,14 +11,14 @@ module Watir
11
11
  @options = options.dup
12
12
  Watir.logger.info "Creating Browser instance of #{browser} with user provided options: #{@options.inspect}"
13
13
 
14
- deprecate_options_capabilities
15
- deprecate_desired_capabilities
16
- deprecate_url_service if @options.key?(:service) && @options.key?(:url)
14
+ if @options.key?(:capabilities) && @options.key?(:options)
15
+ raise(ArgumentError, ':capabilities and :options are not both allowed')
16
+ end
17
+ raise(ArgumentError, ':url and :service are not both allowed') if @options.key?(:service) && @options.key?(:url)
17
18
 
18
- @browser = deprecate_remote(browser) || browser.nil? && infer_browser || browser.to_sym
19
+ @browser = browser.nil? && infer_browser || browser
19
20
 
20
- @selenium_browser = options[:url] ? :remote : @browser
21
- @selenium_opts = {}
21
+ @selenium_browser = @options.key?(:url) ? :remote : @browser
22
22
  end
23
23
 
24
24
  def to_args
@@ -28,270 +28,94 @@ module Watir
28
28
  private
29
29
 
30
30
  def process_arguments
31
- @selenium_opts[:listener] = @options.delete(:listener) if @options.key?(:listener)
31
+ selenium_opts = {}
32
+ selenium_opts[:listener] = @options.delete(:listener) if @options.key?(:listener)
32
33
 
33
34
  if @options.key?(:url)
34
- @selenium_opts[:url] = @options.delete(:url)
35
+ selenium_opts[:url] = @options.delete(:url)
35
36
  else
36
- process_service(@options.delete(:service))
37
+ service = process_service
38
+ selenium_opts[:service] = service if service
37
39
  end
38
40
 
39
- process_http_client
40
- process_browser_options
41
- process_capabilities
42
- Watir.logger.info "Creating Browser instance with Watir processed options: #{@selenium_opts.inspect}"
41
+ selenium_opts[:http_client] = process_http_client
42
+ selenium_opts[:capabilities] = @options.delete(:capabilities) || process_browser_options
43
43
 
44
- @selenium_opts
44
+ Watir.logger.info "Creating Browser instance with Watir processed options: #{selenium_opts.inspect}"
45
+ selenium_opts
45
46
  end
46
47
 
47
48
  def process_http_client
48
49
  http_client = @options.delete(:http_client) || Watir::HttpClient.new
49
- if http_client.is_a?(Hash)
50
- http_client = Watir::HttpClient.new(http_client)
51
- elsif !http_client.is_a?(Selenium::WebDriver::Remote::Http::Common)
52
- raise TypeError, ':http_client must be a Hash or a Selenium HTTP Client instance'
53
- end
54
50
 
55
- unless http_client.is_a?(Watir::HttpClient)
51
+ case http_client
52
+ when Hash
53
+ Watir::HttpClient.new(**http_client)
54
+ when Watir::HttpClient
55
+ http_client
56
+ when Selenium::WebDriver::Remote::Http::Common
56
57
  Watir.logger.warn 'Check out the new Watir::HttpClient and let us know if there are missing features you need',
57
58
  ids: [:watir_client]
59
+ http_client
60
+ else
61
+ raise TypeError, ':http_client must be a Hash or a Selenium HTTP Client instance'
58
62
  end
59
-
60
- process_http_client_timeouts(http_client)
61
- @selenium_opts[:http_client] = http_client
62
63
  end
63
64
 
64
65
  def process_browser_options
65
66
  browser_options = @options.delete(:options) || {}
66
- process_w3c_capabilities(browser_options)
67
-
68
- case @browser
69
- when :chrome
70
- process_chrome_options(browser_options)
71
- when :firefox
72
- process_firefox_options(browser_options)
73
- when :safari
74
- process_safari_options(browser_options)
75
- when :ie, :internet_explorer
76
- process_ie_options(browser_options)
77
- end
78
- end
79
-
80
- def process_capabilities
81
- caps = @options.delete(:capabilities)
82
-
83
- unless @options.empty?
84
- Watir.logger.deprecate('passing unrecognized arguments into Browser constructor',
85
- 'appropriate keyword to nest all arguments',
86
- ids: %i[unknown_keyword capabilities],
87
- reference: 'http://watir.com/guides/capabilities.html')
88
- end
89
-
90
- if caps
91
- @selenium_opts.merge!(@options)
92
- else
93
- caps = Selenium::WebDriver::Remote::Capabilities.send @browser, @options.merge(@w3c_caps)
94
- end
95
-
96
- @selenium_opts[:desired_capabilities] = caps
97
- end
98
-
99
- def deprecate_desired_capabilities
100
- return unless @options.key?(:desired_capabilities)
101
-
102
- Watir.logger.deprecate(':desired_capabilities to initialize Browser',
103
- ':capabilities or preferably :options',
104
- ids: [:desired_capabilities],
105
- reference: 'http://watir.com/guides/capabilities.html')
106
- @options[:capabilities] = @options.delete(:desired_capabilities)
107
- end
108
-
109
- def deprecate_url_service
110
- Watir.logger.deprecate('allowing Browser initialization with both :url & :service',
111
- 'just :service',
112
- ids: [:url_service],
113
- reference: 'http://watir.com/guides/capabilities.html')
114
- end
115
-
116
- def process_http_client_timeouts(http_client)
117
- deprecate_client_timeout(http_client) if @options.key? :client_timeout
118
- deprecate_open_timeout(http_client) if @options.key? :open_timeout
119
- deprecate_read_timeout(http_client) if @options.key? :read_timeout
120
- end
121
-
122
- def deprecate_client_timeout(http_client)
123
- Watir.logger.deprecate(':client_timeout to initialize Browser',
124
- ':open_timeout and/or :read_timeout in a Hash with :http_client key',
125
- ids: [:http_client_timeout],
126
- reference: 'http://watir.com/guides/capabilities.html')
127
- timeout = @options.delete(:client_timeout)
128
- http_client.open_timeout = timeout
129
- http_client.read_timeout = timeout
130
- end
131
-
132
- def deprecate_open_timeout(http_client)
133
- Watir.logger.deprecate(':open_timeout to initialize Browser',
134
- ':open_timeout in a Hash with :http_client key',
135
- ids: %i[http_open_timeout capabilities],
136
- reference: 'http://watir.com/guides/capabilities.html')
137
- http_client.open_timeout = @options.delete(:open_timeout)
138
- end
139
-
140
- def deprecate_read_timeout(http_client)
141
- Watir.logger.deprecate(':read_timeout to initialize Browser',
142
- ':read_timeout in a Hash with :http_client key',
143
- ids: %i[http_read_timeout capabilities],
144
- reference: 'http://watir.com/guides/capabilities.html')
145
- http_client.read_timeout = @options.delete(:read_timeout)
146
- end
147
-
148
- def process_chrome_options(browser_options)
149
- @selenium_opts[:options] = browser_options if browser_options.is_a? Selenium::WebDriver::Chrome::Options
150
- @selenium_opts[:options] ||= Selenium::WebDriver::Chrome::Options.new(**browser_options)
151
67
 
152
- process_args
68
+ options = browser_options if browser_options.is_a? Selenium::WebDriver::Options
69
+ options ||= Selenium::WebDriver::Options.send(@browser, **browser_options)
153
70
 
154
- return unless @options.delete(:headless)
71
+ browser_specific_options(options)
72
+ raise ArgumentError, "#{@options} are unrecognized arguments for Browser constructor" unless @options.empty?
155
73
 
156
- @selenium_opts[:options].args << '--headless'
157
- @selenium_opts[:options].args << '--disable-gpu'
74
+ options
158
75
  end
159
76
 
160
- def process_firefox_options(browser_options)
161
- @selenium_opts[:options] = browser_options if browser_options.is_a? Selenium::WebDriver::Firefox::Options
162
-
163
- @selenium_opts[:options] ||= Selenium::WebDriver::Firefox::Options.new(**browser_options)
164
- if @options.key?(:profile)
165
- new = 'Initializing Browser with both :profile and :option'
166
- old = ':profile as a key inside :option'
167
- Watir.logger.deprecate new, old, ids: [:firefox_profile]
168
-
169
- @selenium_opts[:options].profile = @options.delete(:profile)
77
+ def browser_specific_options(options)
78
+ case @browser
79
+ when :chrome, :edge, :microsoftedge
80
+ if @options.delete(:headless)
81
+ options.args << '--headless'
82
+ options.args << '--disable-gpu'
83
+ options.args << '--no-sandbox'
84
+ end
85
+ when :firefox
86
+ options.headless! if @options.delete(:headless)
87
+ when :safari
88
+ Selenium::WebDriver::Safari.technology_preview! if @options.delete(:technology_preview)
170
89
  end
171
-
172
- @selenium_opts[:options].args << '--headless' if @options.delete(:headless)
173
- end
174
-
175
- def process_safari_options(browser_options)
176
- @selenium_opts[:options] = browser_options if browser_options.is_a? Selenium::WebDriver::Safari::Options
177
- @selenium_opts[:options] ||= Selenium::WebDriver::Safari::Options.new(**browser_options)
178
- Selenium::WebDriver::Safari.technology_preview! if @options.delete(:technology_preview)
179
90
  end
180
91
 
181
- def process_ie_options(browser_options)
182
- @selenium_opts[:options] = browser_options if browser_options.is_a? Selenium::WebDriver::IE::Options
183
- @selenium_opts[:options] ||= Selenium::WebDriver::IE::Options.new(**browser_options)
92
+ def process_service
93
+ service = @options.delete(:service)
184
94
 
185
- process_args
186
- end
95
+ case service
96
+ when nil
97
+ nil
98
+ when Hash
99
+ return if service.empty?
187
100
 
188
- def process_service(service)
189
- service = deprecate_service_keywords if service.nil?
190
-
191
- @selenium_opts[:service] = case service
192
- when Hash
193
- return if service.empty?
194
-
195
- Selenium::WebDriver::Service.send(@browser, service)
196
- when Selenium::WebDriver::Service
197
- service
198
- else
199
- raise TypeError, "#{service} needs to be Selenium Service or Hash instance"
200
- end
201
- end
202
-
203
- def deprecate_service_keywords
204
- service = {}
205
- if @options.key?(:port)
206
- Watir.logger.deprecate(':port to initialize Browser',
207
- ':port in a Hash with :service key',
208
- ids: %i[port_keyword capabilities],
209
- reference: 'http://watir.com/guides/capabilities.html')
210
- service[:port] = @options.delete(:port)
211
- end
212
- if @options.key?(:driver_opts)
213
- Watir.logger.deprecate(':driver_opts to initialize Browser',
214
- ':args as Array in a Hash with :service key',
215
- ids: %i[driver_opts_keyword capabilities],
216
- reference: 'http://watir.com/guides/capabilities.html')
217
- service[:args] = @options.delete(:driver_opts)
101
+ Selenium::WebDriver::Service.send(@browser, **service)
102
+ when Selenium::WebDriver::Service
103
+ service
104
+ else
105
+ raise TypeError, "#{service} needs to be Selenium Service or Hash instance"
218
106
  end
219
- service
220
- end
221
-
222
- def process_args
223
- args = if @options.key?(:args)
224
- deprecate_args
225
- @options.delete(:args)
226
- elsif @options.key?(:switches)
227
- deprecate_switches
228
- @options.delete(:switches)
229
- else
230
- []
231
- end
232
- args.each { |arg| @selenium_opts[:options].args << arg }
233
- end
234
-
235
- def deprecate_args
236
- Watir.logger.deprecate(':args to initialize Browser',
237
- ':args inside Hash with :options key',
238
- ids: %i[args_keyword capabilities],
239
- reference: 'http://watir.com/guides/capabilities.html')
240
- end
241
-
242
- def deprecate_switches
243
- Watir.logger.deprecate(':switches to initialize Browser',
244
- ':switches inside Hash with :options key',
245
- ids: %i[switches_keyword capabilities],
246
- reference: 'http://watir.com/guides/capabilities.html')
247
- end
248
-
249
- def deprecate_remote(browser)
250
- return unless browser == :remote
251
-
252
- Watir.logger.deprecate(':remote to initialize Browser',
253
- 'browser key along with remote url',
254
- ids: %i[remote_keyword capabilities],
255
- reference: 'http://watir.com/guides/capabilities.html')
256
- infer_browser
257
107
  end
258
108
 
259
109
  def infer_browser
260
110
  if @options.key?(:browser)
261
111
  @options.delete(:browser)
262
112
  elsif @options.key?(:capabilities)
263
- @options[:capabilities].browser_name.tr(' ', '_').to_sym
113
+ @options[:capabilities].browser_name.tr(' ', '_').downcase.to_sym
264
114
  elsif @options.key?(:options)
265
115
  @options[:options].class.to_s.split('::')[-2].downcase.to_sym
266
116
  else
267
117
  :chrome
268
118
  end
269
119
  end
270
-
271
- def process_w3c_capabilities(opts)
272
- @w3c_caps = {}
273
- return unless opts.is_a?(Hash)
274
-
275
- w3c_keys = %i[browser_version platform_name accept_insecure_certs page_load_strategy proxy set_window_rect
276
- timeouts unhandled_prompt_behavior strict_file_interactibility]
277
-
278
- opts.each do |key, _val|
279
- next unless key.to_s.include?(':') || w3c_keys.include?(key)
280
-
281
- @w3c_caps[key] = opts.delete(key)
282
- end
283
- end
284
-
285
- def deprecate_options_capabilities
286
- return unless @options.key?(:capabilities) && @options.key?(:options)
287
-
288
- old = 'initializing Browser with both options and capabilities'
289
- new = 'Hash with :options, Selenium Options instance with :options or' \
290
- 'Selenium Capabilities instance with :capabilities'
291
- Watir.logger.deprecate(old,
292
- new,
293
- ids: %i[options_capabilities capabilities],
294
- reference: 'http://watir.com/guides/capabilities.html')
295
- end
296
120
  end
297
121
  end