Skip to content

Commit ecd1285

Browse files
committed
[rb] update syntax for rubocop
1 parent bafb63d commit ecd1285

Some content is hidden

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

41 files changed

+156
-109
lines changed

rb/lib/selenium/server.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def stop
210210
begin
211211
Net::HTTP.get(@host, '/selenium-server/driver/?cmd=shutDownSeleniumServer', @port)
212212
rescue Errno::ECONNREFUSED
213+
nil
213214
end
214215

215216
stop_process if @process

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class BrowsingContext
3434

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

4041
unless type.nil? || %i[window tab].include?(type)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class BiDi
2323
class ConsoleLogEntry < GenericLogEntry
2424
attr_accessor :method, :realm, :args
2525

26-
def initialize(level:, text:, timestamp:, type:, method:, realm:, args:, stack_trace:)
27-
super(level: level, text: text, timestamp: timestamp, type: type, stack_trace: stack_trace)
26+
def initialize(method:, realm:, args:, **opts)
27+
super(**opts)
2828
@method = method
2929
@realm = realm
3030
@args = args

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class LogInspector
4141

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

4748
@bidi = driver.bidi

rb/lib/selenium/webdriver/common/driver.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,19 +255,19 @@ def add_virtual_authenticator(options)
255255
# driver.first(id: 'foo')
256256
#
257257

258-
alias_method :first, :find_element
258+
alias first find_element
259259

260260
#
261261
# driver.all(class: 'bar') #=> [#<WebDriver::Element:0x1011c3b88, ...]
262262
#
263263

264-
alias_method :all, :find_elements
264+
alias all find_elements
265265

266266
#
267267
# driver.script('function() { ... };')
268268
#
269269

270-
alias_method :script, :execute_script
270+
alias script execute_script
271271

272272
# Get the first element matching the given selector. If given a
273273
# String or Symbol, it will be used as the id of the element.

rb/lib/selenium/webdriver/common/driver_extensions/has_location.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def location
2929
def location=(*)
3030
raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting location'
3131
end
32-
alias_method :set_location, :location
32+
alias set_location location
3333
end # HasLocation
3434
end # DriverExtensions
3535
end # WebDriver

rb/lib/selenium/webdriver/common/element.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def inspect
4343
def ==(other)
4444
other.is_a?(self.class) && ref == other.ref
4545
end
46-
alias_method :eql?, :==
46+
alias eql? ==
4747

4848
def hash
4949
[@id, @bridge].hash
@@ -207,7 +207,7 @@ def text
207207
def send_keys(*args)
208208
bridge.send_keys_to_element @id, Keys.encode(args)
209209
end
210-
alias_method :send_key, :send_keys
210+
alias send_key send_keys
211211

212212
#
213213
# If this element is a text entry element, this will clear the value. Has no effect on other
@@ -275,7 +275,7 @@ def submit
275275
def css_value(prop)
276276
bridge.element_value_of_css_property @id, prop
277277
end
278-
alias_method :style, :css_value
278+
alias style css_value
279279

280280
#
281281
# Get the location of this element.
@@ -333,18 +333,18 @@ def shadow_root
333333
# element.first(id: 'foo')
334334
#
335335

336-
alias_method :first, :find_element
336+
alias first find_element
337337

338338
#
339339
# element.all(class: 'bar')
340340
#
341341

342-
alias_method :all, :find_elements
342+
alias all find_elements
343343

344344
#
345345
# element['class'] or element[:class] #=> "someclass"
346346
#
347-
alias_method :[], :attribute
347+
alias [] attribute
348348

349349
#
350350
# @api private

rb/lib/selenium/webdriver/common/html5/shared_web_storage.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ module SharedWebStorage
2626
def key?(key)
2727
keys.include? key
2828
end
29-
alias_method :member?, :key?
30-
alias_method :has_key?, :key?
29+
alias member? key?
30+
alias has_key? key?
3131

3232
def fetch(key)
3333
return self[key] if key? key

rb/lib/selenium/webdriver/common/interactions/pointer_actions.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def pointer_up(button = :left, device: nil, **opts)
9595
# @return [ActionBuilder] A self reference.
9696
#
9797

98-
def move_to(element, right_by = nil, down_by = nil, device: nil, duration: default_move_duration, **opts)
99-
pointer = pointer_input(device)
100-
pointer.create_pointer_move(duration: duration,
98+
def move_to(element, right_by = nil, down_by = nil, **opts)
99+
pointer = pointer_input(opts.delete(:device))
100+
pointer.create_pointer_move(duration: opts.delete(:duration) || default_move_duration,
101101
x: right_by || 0,
102102
y: down_by || 0,
103103
origin: element,

rb/lib/selenium/webdriver/common/interactions/pointer_move.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ class PointerMove < Interaction
3333
POINTER = :pointer
3434
ORIGINS = [VIEWPORT, POINTER].freeze
3535

36-
def initialize(source, duration, x, y, element: nil, origin: nil, **opts)
36+
def initialize(source, duration, x, y, **opts)
3737
super(source)
3838
@duration = duration * 1000
3939
@x_offset = x
4040
@y_offset = y
41-
@origin = element || origin || :viewport
41+
@origin = opts.delete(:element) || opts.delete(:origin) || :viewport
4242
@type = :pointerMove
4343
@opts = opts
4444
end

0 commit comments

Comments
 (0)