Skip to content

Commit 8c001ee

Browse files
committed
rb - update deprecated methods
1 parent 9551fe6 commit 8c001ee

File tree

27 files changed

+70
-102
lines changed

27 files changed

+70
-102
lines changed

rb/.rubocop_todo.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2016-06-09 12:14:10 -0700 using RuboCop version 0.37.2.
3+
# on 2016-06-09 13:11:15 -0700 using RuboCop version 0.37.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 2
10-
# Cop supports --auto-correct.
11-
Lint/DeprecatedClassMethods:
12-
Exclude:
13-
- 'lib/selenium/server.rb'
14-
159
# Offense count: 10
1610
Lint/HandleExceptions:
1711
Exclude:
@@ -60,7 +54,7 @@ Metrics/ClassLength:
6054
Metrics/CyclomaticComplexity:
6155
Max: 16
6256

63-
# Offense count: 713
57+
# Offense count: 711
6458
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
6559
# URISchemes: http, https
6660
Metrics/LineLength:
@@ -114,13 +108,6 @@ Style/ClassAndModuleChildren:
114108
- 'spec/integration/selenium/webdriver/storage_spec.rb'
115109
- 'spec/integration/selenium/webdriver/touch_spec.rb'
116110

117-
# Offense count: 36
118-
# Cop supports --auto-correct.
119-
# Configuration parameters: EnforcedStyle, SupportedStyles.
120-
# SupportedStyles: is_a?, kind_of?
121-
Style/ClassCheck:
122-
Enabled: false
123-
124111
# Offense count: 3
125112
# Cop supports --auto-correct.
126113
# Configuration parameters: Keywords.
@@ -135,19 +122,6 @@ Style/ConstantName:
135122
Exclude:
136123
- 'lib/selenium/webdriver/common/error.rb'
137124

138-
# Offense count: 31
139-
# Cop supports --auto-correct.
140-
Style/DeprecatedHashMethods:
141-
Exclude:
142-
- 'lib/selenium/webdriver/android/bridge.rb'
143-
- 'lib/selenium/webdriver/chrome/bridge.rb'
144-
- 'lib/selenium/webdriver/common/proxy.rb'
145-
- 'lib/selenium/webdriver/edge/bridge.rb'
146-
- 'lib/selenium/webdriver/firefox/profile.rb'
147-
- 'lib/selenium/webdriver/iphone/bridge.rb'
148-
- 'lib/selenium/webdriver/phantomjs/bridge.rb'
149-
- 'lib/selenium/webdriver/remote/capabilities.rb'
150-
151125
# Offense count: 84
152126
Style/Documentation:
153127
Enabled: false

rb/lib/selenium/server.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def download(required_version)
7070
required_version = latest if required_version == :latest
7171
download_file_name = "selenium-server-standalone-#{required_version}.jar"
7272

73-
return download_file_name if File.exists? download_file_name
73+
return download_file_name if File.exist? download_file_name
7474

7575
begin
7676
open(download_file_name, "wb") do |destination|
@@ -94,13 +94,13 @@ def download(required_version)
9494
end
9595
end
9696

97-
unless resp.kind_of? Net::HTTPSuccess
97+
unless resp.is_a? Net::HTTPSuccess
9898
raise Error, "#{resp.code} for #{download_file_name}"
9999
end
100100
end
101101
end
102102
rescue
103-
FileUtils.rm download_file_name if File.exists? download_file_name
103+
FileUtils.rm download_file_name if File.exist? download_file_name
104104
raise
105105
end
106106

@@ -207,7 +207,7 @@ def webdriver_url
207207
end
208208

209209
def <<(arg)
210-
if arg.kind_of?(Array)
210+
if arg.is_a?(Array)
211211
@additional_args += arg
212212
else
213213
@additional_args << arg.to_s
@@ -235,7 +235,7 @@ def process
235235
cp = ChildProcess.build("java", "-jar", @jar, "-port", @port.to_s, *@additional_args)
236236
io = cp.io
237237

238-
if @log.kind_of?(String)
238+
if @log.is_a?(String)
239239
@log_file = File.open(@log, "w")
240240
io.stdout = io.stderr = @log_file
241241
elsif @log

rb/lib/selenium/webdriver/android/bridge.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def initialize(opts = {})
3535
desired_capabilities: opts.fetch(:desired_capabilities, capabilities),
3636
}
3737

38-
remote_opts[:http_client] = opts[:http_client] if opts.has_key?(:http_client)
38+
remote_opts[:http_client] = opts[:http_client] if opts.key?(:http_client)
3939

4040
super remote_opts
4141
end

rb/lib/selenium/webdriver/chrome/bridge.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Bridge < Remote::Bridge
2525
def initialize(opts = {})
2626
http_client = opts.delete(:http_client)
2727

28-
if opts.has_key?(:url)
28+
if opts.key?(:url)
2929
url = opts.delete(:url)
3030
else
3131
@service = Service.new(Chrome.driver_path, Service::DEFAULT_PORT, *extract_service_args(opts))
@@ -88,7 +88,7 @@ def create_capabilities(opts)
8888
chrome_options = caps['chromeOptions'] || {}
8989

9090
if args
91-
unless args.kind_of? Array
91+
unless args.is_a? Array
9292
raise ArgumentError, ":args must be an Array of Strings"
9393
end
9494

@@ -124,7 +124,7 @@ def create_capabilities(opts)
124124
def extract_service_args(opts)
125125
args = []
126126

127-
if opts.has_key?(:service_log_path)
127+
if opts.key?(:service_log_path)
128128
args << "--log-path=#{opts.delete(:service_log_path)}"
129129
end
130130

rb/lib/selenium/webdriver/common/action_builder.rb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ def initialize(mouse, keyboard)
7878
#
7979

8080
def key_down(*args)
81-
if args.first.kind_of? Element
82-
@actions << [:mouse, :click, [args.shift]]
83-
end
81+
@actions << [:mouse, :click, [args.shift]] if args.first.is_a? Element
8482

8583
@actions << [:keyboard, :press, args]
8684
self
@@ -106,9 +104,7 @@ def key_down(*args)
106104
#
107105

108106
def key_up(*args)
109-
if args.first.kind_of? Element
110-
@actions << [:mouse, :click, [args.shift]]
111-
end
107+
@actions << [:mouse, :click, [args.shift]] if args.first.is_a? Element
112108

113109
@actions << [:keyboard, :release, args]
114110
self
@@ -136,9 +132,7 @@ def key_up(*args)
136132
#
137133

138134
def send_keys(*args)
139-
if args.first.kind_of? Element
140-
@actions << [:mouse, :click, [args.shift]]
141-
end
135+
@actions << [:mouse, :click, [args.shift]] if args.first.is_a? Element
142136

143137
@actions << [:keyboard, :send_keys, args]
144138
self

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def execute_async_script(script, *args)
269269
#
270270

271271
def [](sel)
272-
sel = {id: sel} if sel.kind_of?(String) || sel.kind_of?(Symbol)
272+
sel = {id: sel} if sel.is_a?(String) || sel.is_a?(Symbol)
273273

274274
find_element sel
275275
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def location
2626
end
2727

2828
def location=(loc)
29-
unless loc.kind_of?(Location)
29+
unless loc.is_a?(Location)
3030
raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}"
3131
end
3232

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def inspect
3737
end
3838

3939
def ==(other)
40-
other.kind_of?(self.class) && ref == other.ref
40+
other.is_a?(self.class) && ref == other.ref
4141
end
4242
alias_method :eql?, :==
4343

rb/lib/selenium/webdriver/common/keys.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def self.encode(keys)
110110
when Symbol
111111
Keys[arg]
112112
when Array
113-
arg = arg.map { |e| e.kind_of?(Symbol) ? Keys[e] : e }.join
113+
arg = arg.map { |e| e.is_a?(Symbol) ? Keys[e] : e }.join
114114
arg << Keys[:null]
115115

116116
arg

rb/lib/selenium/webdriver/common/mouse.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def move_if_needed(element)
8080
end
8181

8282
def assert_element(element)
83-
return if element.kind_of? Element
83+
return if element.is_a? Element
8484
raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
8585
end
8686
end # Mouse

0 commit comments

Comments
 (0)