Skip to content

Commit a6fbb15

Browse files
committed
Log warning when methods are added to Selenium
1 parent 7fc8c55 commit a6fbb15

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

lib/appium_lib.rb

+1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ def self.add_to_path file, path=false
3030

3131
add_to_path __FILE__
3232

33+
require_relative 'appium_lib/logger'
3334
require_relative 'appium_lib/driver'
3435
end

lib/appium_lib/device/device.rb

+21-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ def delegate_appium_driver_method(method)
6868

6969
def create_bridge_command(method, path)
7070
# Don't clobber methods that are moved into Selenium
71-
return if Selenium::WebDriver::Remote::Bridge.method_defined? method
71+
if selenium_has method
72+
log_reimplemented_warning(method, path)
73+
return
74+
end
75+
7276
Selenium::WebDriver::Remote::Bridge.class_eval do
7377
command method, :post, path
7478
if block_given?
@@ -78,6 +82,22 @@ def create_bridge_command(method, path)
7882
end
7983
end
8084
end
85+
86+
def selenium_has(method)
87+
Selenium::WebDriver::Remote::Bridge.method_defined? method
88+
end
89+
90+
def log_reimplemented_warning(method, path)
91+
msg = "Selenium::WebDriver has now implemented the `#{method}` method."
92+
if Selenium::WebDriver::Remote::COMMANDS[method][1] == path
93+
msg << " It may no longer function as expected"
94+
else
95+
msg << " It no longer uses the same endpoint,"
96+
msg << " so it probably won't do what you expect anymore."
97+
end
98+
msg << " Raise an issue at http://www.github.com/appium/ruby_lib if so."
99+
Appium::Logger.warn msg
100+
end
81101
end
82102
end
83103
end

lib/appium_lib/logger.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module Appium
2+
module Logger
3+
class << self
4+
extend Forwardable
5+
def_delegators :@logger, :warn, :error, :info
6+
7+
def logger
8+
@logger ||= Logger.new
9+
end
10+
end
11+
end
12+
end

0 commit comments

Comments
 (0)