Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rb/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ Metrics/PerceivedComplexity:
- 'lib/selenium/webdriver/common/local_driver.rb'
- 'lib/selenium/webdriver/common/logger.rb'

Naming/BlockForwarding:
EnforcedStyle: explicit

Naming/FileName:
Exclude:
- 'lib/selenium-webdriver.rb'
Expand Down
6 changes: 3 additions & 3 deletions rb/lib/selenium/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ def available_assets
end
end

def net_http_start(address, &)
def net_http_start(address, &block)
http_proxy = ENV.fetch('http_proxy', nil) || ENV.fetch('HTTP_PROXY', nil)
if http_proxy
http_proxy = "http://#{http_proxy}" unless http_proxy.start_with?('http://')
uri = URI.parse(http_proxy)

Net::HTTP.start(address, nil, uri.host, uri.port, &)
Net::HTTP.start(address, nil, uri.host, uri.port, &block)
else
Net::HTTP.start(address, use_ssl: true, &)
Net::HTTP.start(address, use_ssl: true, &block)
end
end

Expand Down
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/bidi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def callbacks
@ws.callbacks
end

def add_callback(event, &)
@ws.add_callback(event, &)
def add_callback(event, &block)
@ws.add_callback(event, &block)
end

def remove_callback(event, id)
Expand Down
8 changes: 4 additions & 4 deletions rb/lib/selenium/webdriver/bidi/log_inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def on_javascript_exception(&block)
end
end

def on_log(filter_by = nil, &)
def on_log(filter_by = nil, &block)
unless filter_by.nil?
check_valid_filter(filter_by)

Expand All @@ -89,14 +89,14 @@ def on_log(filter_by = nil, &)
return
end

on(:entry_added, &)
on(:entry_added, &block)
end

private

def on(event, &)
def on(event, &block)
event = EVENTS[event] if event.is_a?(Symbol)
@bidi.add_callback("log.#{event}", &)
@bidi.add_callback("log.#{event}", &block)
end

def check_valid_filter(filter_by)
Expand Down
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/bidi/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ def set_cache_behavior(behavior, *contexts)
@bidi.send_cmd('network.setCacheBehavior', cacheBehavior: behavior, contexts: contexts)
end

def on(event, &)
def on(event, &block)
event = EVENTS[event] if event.is_a?(Symbol)
@bidi.add_callback(event, &)
@bidi.add_callback(event, &block)
@bidi.session.subscribe(event)
end
end # Network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module HasNetworkInterception
# @yieldparam [Proc] continue block which proceeds with the request and optionally yields response
#

def intercept(&)
def intercept(&block)
if browser == :firefox
WebDriver.logger.deprecate(
'Driver#intercept on Firefox',
Expand All @@ -68,7 +68,7 @@ def intercept(&)
)
end
@interceptor ||= DevTools::NetworkInterceptor.new(devtools)
@interceptor.intercept(&)
@interceptor.intercept(&block)
end
end # HasNetworkInterception
end # DriverExtensions
Expand Down
8 changes: 4 additions & 4 deletions rb/lib/selenium/webdriver/common/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@ def add_authentication_handler(username = nil, password = nil, *filter, pattern_
)
end

def add_request_handler(*filter, pattern_type: nil, &)
def add_request_handler(*filter, pattern_type: nil, &block)
add_handler(
:before_request,
BiDi::Network::PHASES[:before_request],
BiDi::InterceptedRequest,
filter,
pattern_type: pattern_type,
&
&block
)
end

def add_response_handler(*filter, pattern_type: nil, &)
def add_response_handler(*filter, pattern_type: nil, &block)
add_handler(
:response_started,
BiDi::Network::PHASES[:response_started],
BiDi::InterceptedResponse,
filter,
pattern_type: pattern_type,
&
&block
)
end

Expand Down
8 changes: 4 additions & 4 deletions rb/lib/selenium/webdriver/common/script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def initialize(bridge)
end

# @return [int] id of the handler
def add_console_message_handler(&)
@log_handler.add_message_handler('console', &)
def add_console_message_handler(&block)
@log_handler.add_message_handler('console', &block)
end

# @return [int] id of the handler
def add_javascript_error_handler(&)
@log_handler.add_message_handler('javascript', &)
def add_javascript_error_handler(&block)
@log_handler.add_message_handler('javascript', &block)
end

# @param [int] id of the handler previously added
Expand Down
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/remote/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class << self
attr_reader :extra_commands
attr_writer :element_class, :locator_converter

def add_command(name, verb, url, &)
def add_command(name, verb, url, &block)
@extra_commands ||= {}
@extra_commands[name] = [verb, url]
define_method(name, &)
define_method(name, &block)
end

def locator_converter
Expand Down
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/support/guards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def initialize(example, bug_tracker: '', conditions: nil)
@messages = {}
end

def add_condition(name, condition = nil, &)
@guard_conditions << GuardCondition.new(name, condition, &)
def add_condition(name, condition = nil, &block)
@guard_conditions << GuardCondition.new(name, condition, &block)
end

def add_message(name, message)
Expand Down
Loading