Skip to content

Commit 53922c2

Browse files
committed
[rb] update styling for rubocop
1 parent ecd1285 commit 53922c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+288
-288
lines changed

rb/lib/selenium/webdriver/atoms.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def read_atom(function)
2727
end
2828

2929
def execute_atom(function_name, *arguments)
30-
script = format("/* #{function_name} */ return (%<atom>s).apply(null, arguments)",
30+
script = format("/* #{function_name} */return (%<atom>s).apply(null, arguments)",
3131
atom: read_atom(function_name))
3232
execute_script(script, *arguments)
3333
end

rb/lib/selenium/webdriver/bidi/browsing_context.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ class BrowsingContext
2727
attr_accessor :id
2828

2929
READINESS_STATE = {
30-
none: "none",
31-
interactive: "interactive",
32-
complete: "complete"
30+
none: 'none',
31+
interactive: 'interactive',
32+
complete: 'complete'
3333
}.freeze
3434

3535
def initialize(driver:, browsing_context_id: nil, type: nil, reference_context: nil)
3636
unless driver.capabilities.web_socket_url
3737
raise Error::WebDriverError,
38-
"WebDriver instance must support BiDi protocol"
38+
'WebDriver instance must support BiDi protocol'
3939
end
4040

4141
unless type.nil? || %i[window tab].include?(type)
@@ -44,7 +44,7 @@ def initialize(driver:, browsing_context_id: nil, type: nil, reference_context:
4444
end
4545

4646
@bidi = driver.bidi
47-
@id = browsing_context_id.nil? ? create(type, reference_context)["context"] : browsing_context_id
47+
@id = browsing_context_id.nil? ? create(type, reference_context)['context'] : browsing_context_id
4848
end
4949

5050
def navigate(url:, readiness_state: nil)
@@ -53,17 +53,17 @@ def navigate(url:, readiness_state: nil)
5353
"Valid readiness states are :none, :interactive & :complete. Received: #{readiness_state.inspect}"
5454
end
5555

56-
navigate_result = @bidi.send_cmd("browsingContext.navigate", context: @id, url: url,
56+
navigate_result = @bidi.send_cmd('browsingContext.navigate', context: @id, url: url,
5757
wait: READINESS_STATE[readiness_state])
5858

5959
NavigateResult.new(
60-
url: navigate_result["url"],
61-
navigation_id: navigate_result["navigation"]
60+
url: navigate_result['url'],
61+
navigation_id: navigate_result['navigation']
6262
)
6363
end
6464

6565
def get_tree(max_depth: nil)
66-
result = @bidi.send_cmd("browsingContext.getTree", root: @id, maxDepth: max_depth).dig("contexts", 0)
66+
result = @bidi.send_cmd('browsingContext.getTree', root: @id, maxDepth: max_depth).dig('contexts', 0)
6767

6868
BrowsingContextInfo.new(
6969
id: result['context'],
@@ -74,13 +74,13 @@ def get_tree(max_depth: nil)
7474
end
7575

7676
def close
77-
@bidi.send_cmd("browsingContext.close", context: @id)
77+
@bidi.send_cmd('browsingContext.close', context: @id)
7878
end
7979

8080
private
8181

8282
def create(type, reference_context)
83-
@bidi.send_cmd("browsingContext.create", type: type.to_s, referenceContext: reference_context)
83+
@bidi.send_cmd('browsingContext.create', type: type.to_s, referenceContext: reference_context)
8484
end
8585
end # BrowsingContext
8686
end # BiDi

rb/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class JavascriptLogEntry < GenericLogEntry
2525

2626
def initialize(level:, text:, timestamp:, type:, stack_trace:)
2727
super(level: level, text: text, timestamp: timestamp, type: type, stack_trace: stack_trace)
28-
@type = "javascript"
28+
@type = 'javascript'
2929
end
3030
end # JavascriptLogEntry
3131
end # BiDi

rb/lib/selenium/webdriver/bidi/log_inspector.rb

+13-13
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ class LogInspector
3333
}.freeze
3434

3535
LOG_LEVEL = {
36-
DEBUG: "debug",
37-
ERROR: "error",
38-
INFO: "info",
39-
WARNING: "warning"
36+
DEBUG: 'debug',
37+
ERROR: 'error',
38+
INFO: 'info',
39+
WARNING: 'warning'
4040
}.freeze
4141

4242
def initialize(driver, browsing_context_ids = nil)
4343
unless driver.capabilities.web_socket_url
4444
raise Error::WebDriverError,
45-
"WebDriver instance must support BiDi protocol"
45+
'WebDriver instance must support BiDi protocol'
4646
end
4747

4848
@bidi = driver.bidi
49-
@bidi.session.subscribe("log.entryAdded", browsing_context_ids)
49+
@bidi.session.subscribe('log.entryAdded', browsing_context_ids)
5050
end
5151

5252
def on_console_entry(&block)
@@ -55,8 +55,8 @@ def on_console_entry(&block)
5555
return if enabled
5656

5757
on_log do |params|
58-
type = params["type"]
59-
console_log_events(params) if type.eql?("console")
58+
type = params['type']
59+
console_log_events(params) if type.eql?('console')
6060
end
6161
end
6262

@@ -66,8 +66,8 @@ def on_javascript_log(&block)
6666
return if enabled
6767

6868
on_log do |params|
69-
type = params["type"]
70-
javascript_log_events(params) if type.eql?("javascript")
69+
type = params['type']
70+
javascript_log_events(params) if type.eql?('javascript')
7171
end
7272
end
7373

@@ -78,10 +78,10 @@ def on_javascript_exception(&block)
7878
return if enabled
7979

8080
on_log do |params|
81-
type = params["type"]
82-
level = params["level"]
81+
type = params['type']
82+
level = params['level']
8383

84-
javascript_log_events(params) if type.eql?("javascript") && level.eql?(LOG_LEVEL[:ERROR])
84+
javascript_log_events(params) if type.eql?('javascript') && level.eql?(LOG_LEVEL[:ERROR])
8585
end
8686
end
8787

rb/lib/selenium/webdriver/bidi/session.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ def subscribe(events, browsing_contexts = nil)
3636
events_list = Array(events)
3737
browsing_contexts_list = browsing_contexts.nil? ? nil : Array(browsing_contexts)
3838

39-
@bidi.send_cmd("session.subscribe", events: events_list, contexts: browsing_contexts_list)
39+
@bidi.send_cmd('session.subscribe', events: events_list, contexts: browsing_contexts_list)
4040
end
4141

4242
def unsubscribe(events, browsing_contexts = nil)
4343
events_list = Array(events)
4444
browsing_contexts_list = browsing_contexts.nil? ? nil : Array(browsing_contexts)
4545

46-
@bidi.send_cmd("session.unsubscribe", events: events_list, contexts: browsing_contexts_list)
46+
@bidi.send_cmd('session.unsubscribe', events: events_list, contexts: browsing_contexts_list)
4747
end
4848
end # Session
4949
end # BiDi

rb/lib/selenium/webdriver/chromium/options.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def check_w3c(w3c)
241241

242242
raise Error::InvalidArgumentError,
243243
"Setting 'w3c: false' is not allowed.\n" \
244-
"Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/"
244+
'Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/'
245245
end
246246

247247
def binary_path

rb/lib/selenium/webdriver/chromium/service.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def extract_service_args(driver_opts)
3232
if driver_opts.key?(:whitelisted_ips)
3333
driver_args << "--whitelisted-ips=#{driver_opts.delete(:whitelisted_ips)}"
3434
end
35-
driver_args << "--verbose" if driver_opts.key?(:verbose)
36-
driver_args << "--silent" if driver_opts.key?(:silent)
35+
driver_args << '--verbose' if driver_opts.key?(:verbose)
36+
driver_args << '--silent' if driver_opts.key?(:silent)
3737
driver_args
3838
end
3939
end # Service

rb/lib/selenium/webdriver/common/profile_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def encoded
4040
end
4141

4242
def as_json(*)
43-
{"zip" => encoded}
43+
{'zip' => encoded}
4444
end
4545

4646
def to_json(*)

rb/lib/selenium/webdriver/common/selenium_manager.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module WebDriver
2727
# @api private
2828
#
2929
class SeleniumManager
30-
BIN_PATH = "../../../../../bin"
30+
BIN_PATH = '../../../../../bin'
3131

3232
class << self
3333
# @param [String] driver_name which driver to use.
@@ -60,7 +60,7 @@ def binary
6060
end
6161
location = File.expand_path(path, __FILE__)
6262
unless location.is_a?(String) && File.exist?(location) && File.executable?(location)
63-
raise Error::WebDriverError, "Unable to obtain Selenium Manager"
63+
raise Error::WebDriverError, 'Unable to obtain Selenium Manager'
6464
end
6565

6666
WebDriver.logger.debug("Selenium Manager found at #{location}")

rb/lib/selenium/webdriver/common/service.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def shutdown_supported
9191
protected
9292

9393
def extract_service_args(driver_opts)
94-
WebDriver.logger.deprecate("initializing Service class with :args using Hash",
95-
":args parameter with an Array of String values",
94+
WebDriver.logger.deprecate('initializing Service class with :args using Hash',
95+
':args parameter with an Array of String values',
9696
id: :driver_opts)
9797
driver_opts.key?(:args) ? driver_opts.delete(:args) : []
9898
end

rb/lib/selenium/webdriver/common/takes_screenshot.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ module TakesScreenshot
3232
def save_screenshot(png_path, full_page: false)
3333
extension = File.extname(png_path).downcase
3434
if extension != '.png'
35-
WebDriver.logger.warn "name used for saved screenshot does not match file type. " \
36-
"It should end with .png extension",
35+
WebDriver.logger.warn 'name used for saved screenshot does not match file type. ' \
36+
'It should end with .png extension',
3737
id: :screenshot
3838
end
3939
File.open(png_path, 'wb') { |f| f << screenshot_as(:png, full_page: full_page) }

rb/lib/selenium/webdriver/common/virtual_authenticator/credential.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def decode(base64)
4444

4545
def from_json(opts)
4646
user_handle = opts['userHandle'] ? decode(opts['userHandle']) : nil
47-
new(id: decode(opts["credentialId"]),
48-
resident_credential: opts["isResidentCredential"],
47+
new(id: decode(opts['credentialId']),
48+
resident_credential: opts['isResidentCredential'],
4949
rp_id: opts['rpId'],
5050
private_key: opts['privateKey'],
5151
sign_count: opts['signCount'],

rb/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
module Selenium
2626
module WebDriver
2727
class VirtualAuthenticatorOptions
28-
PROTOCOL = {ctap2: "ctap2", u2f: "ctap1/u2f"}.freeze
29-
TRANSPORT = {ble: "ble", usb: "usb", nfc: "nfc", internal: "internal"}.freeze
28+
PROTOCOL = {ctap2: 'ctap2', u2f: 'ctap1/u2f'}.freeze
29+
TRANSPORT = {ble: 'ble', usb: 'usb', nfc: 'nfc', internal: 'internal'}.freeze
3030

3131
attr_accessor :protocol, :transport, :resident_key, :user_verification, :user_consenting, :user_verified
3232
alias resident_key? resident_key

rb/lib/selenium/webdriver/common/websocket_connection.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def process_frame(frame)
111111
return {} if message.empty?
112112

113113
message = JSON.parse(message)
114-
messages[message["id"]] = message
114+
messages[message['id']] = message
115115
WebDriver.logger.debug "WebSocket <- #{message}"[...MAX_LOG_MESSAGE_SIZE]
116116

117117
message

rb/lib/selenium/webdriver/devtools/network_interceptor.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class DevTools
3232
class NetworkInterceptor
3333
# CDP fails to get body on certain responses (301) and raises:
3434
# "Can only get response body on requests captured after headers received."
35-
CANNOT_GET_BODY_ON_REDIRECT_ERROR_CODE = "-32000"
35+
CANNOT_GET_BODY_ON_REDIRECT_ERROR_CODE = '-32000'
3636

3737
# CDP fails to operate with intercepted requests.
3838
# Typical reason is browser cancelling intercepted requests/responses.
39-
INVALID_INTERCEPTION_ID_ERROR_CODE = "-32602"
39+
INVALID_INTERCEPTION_ID_ERROR_CODE = '-32602'
4040

4141
def initialize(devtools)
4242
@devtools = devtools

rb/lib/selenium/webdriver/firefox/driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def browser
5252

5353
def devtools_url
5454
if capabilities['moz:debuggerAddress'].nil?
55-
raise(Error::WebDriverError, "DevTools is not supported by this version of Firefox; use v85 or higher")
55+
raise(Error::WebDriverError, 'DevTools is not supported by this version of Firefox; use v85 or higher')
5656
end
5757

5858
uri = URI("http://#{capabilities['moz:debuggerAddress']}")

rb/lib/selenium/webdriver/firefox/options.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def process_profile(profile)
178178
end
179179

180180
def camelize?(key)
181-
key != "prefs"
181+
key != 'prefs'
182182
end
183183
end # Options
184184
end # Firefox

rb/lib/selenium/webdriver/firefox/profile.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class Profile
2626
VALID_PREFERENCE_TYPES = [TrueClass, FalseClass, Integer, Float, String].freeze
2727

2828
DEFAULT_PREFERENCES = {
29-
"browser.newtabpage.enabled" => false,
30-
"browser.startup.homepage" => "about:blank",
31-
"browser.usedOnWindows10.introURL" => "about:blank",
32-
"network.captive-portal-service.enabled" => false,
33-
"security.csp.enable" => false
29+
'browser.newtabpage.enabled' => false,
30+
'browser.startup.homepage' => 'about:blank',
31+
'browser.usedOnWindows10.introURL' => 'about:blank',
32+
'network.captive-portal-service.enabled' => false,
33+
'security.csp.enable' => false
3434
}.freeze
3535

3636
attr_reader :name, :log_file

rb/lib/selenium/webdriver/ie/service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def extract_service_args(driver_opts)
4242
end
4343
driver_args << "--host=#{driver_opts[:host]}" if driver_opts.key?(:host)
4444
driver_args << "--extract_path=#{driver_opts[:extract_path]}" if driver_opts.key?(:extract_path)
45-
driver_args << "--silent" if driver_opts[:silent] == true
45+
driver_args << '--silent' if driver_opts[:silent] == true
4646
driver_args
4747
end
4848
end # Server

rb/lib/selenium/webdriver/remote/bridge.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def submit_element(element)
430430

431431
execute_script(script, Element::ELEMENT_KEY => element)
432432
rescue Error::JavascriptError
433-
raise Error::UnsupportedOperationError, "To submit an element, it must be nested inside a form element"
433+
raise Error::UnsupportedOperationError, 'To submit an element, it must be nested inside a form element'
434434
end
435435

436436
#

rb/lib/selenium/webdriver/remote/capabilities.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def firefox(opts = {})
104104

105105
def safari(opts = {})
106106
new({
107-
browser_name: Selenium::WebDriver::Safari.technology_preview? ? "Safari Technology Preview" : 'safari'
107+
browser_name: Selenium::WebDriver::Safari.technology_preview? ? 'Safari Technology Preview' : 'safari'
108108
}.merge(opts))
109109
end
110110

rb/lib/selenium/webdriver/remote/driver.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def devtools_url
4646

4747
def devtools_version
4848
capabilities['se:cdpVersion']&.split('.')&.first ||
49-
raise(Error::WebDriverError, "DevTools is not supported by the Remote Server")
49+
raise(Error::WebDriverError, 'DevTools is not supported by the Remote Server')
5050
end
5151

5252
def process_options(options, capabilities)

rb/lib/selenium/webdriver/safari.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class << self
2929
attr_accessor :use_technology_preview
3030

3131
def technology_preview
32-
"/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver"
32+
'/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'
3333
end
3434

3535
def technology_preview!

rb/lib/selenium/webdriver/safari/options.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Options < WebDriver::Options
2626
# @see https://developer.apple.com/documentation/webkit/about_webdriver_for_safari
2727
CAPABILITIES = {automatic_inspection: 'safari:automaticInspection',
2828
automatic_profiling: 'safari:automaticProfiling'}.freeze
29-
BROWSER = Selenium::WebDriver::Safari.technology_preview? ? "Safari Technology Preview" : 'safari'
29+
BROWSER = Selenium::WebDriver::Safari.technology_preview? ? 'Safari Technology Preview' : 'safari'
3030

3131
def add_option(name, value = nil)
3232
key = name.is_a?(Hash) ? name.keys.first : name
@@ -36,7 +36,7 @@ def add_option(name, value = nil)
3636
end
3737

3838
def as_json(*)
39-
@options[:browser_name] = Safari.technology_preview? ? "Safari Technology Preview" : 'safari'
39+
@options[:browser_name] = Safari.technology_preview? ? 'Safari Technology Preview' : 'safari'
4040
super
4141
end
4242
end # Options

rb/selenium-devtools.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Gem::Specification.new do |s|
3939
'lib/selenium/devtools.rb'
4040
] + Dir['lib/selenium/devtools/**/*']
4141

42-
s.require_paths = ["lib"]
42+
s.require_paths = ['lib']
4343

4444
s.add_runtime_dependency 'selenium-webdriver', '~> 4.2'
4545
end

0 commit comments

Comments
 (0)