lib/appium_lib/common/patch.rb in appium_lib-9.5.0 vs lib/appium_lib/common/patch.rb in appium_lib-9.6.0
- old
+ new
@@ -25,11 +25,11 @@
# ```ruby
# execute_script 'mobile: tap', :x => 0.0, :y => 0.98
# ```
#
# @return [OpenStruct] the relative x, y in a struct. ex: { x: 0.50, y: 0.20 }
- def location_rel
+ def location_rel(driver = $driver)
# TODO: Remove with 'refine Appium ruby binding'
# https://github.com/appium/ruby_lib/issues/602
if ::Appium.selenium_webdriver_version_more?('3.4.0')
rect = self.rect
location_x = rect.x.to_f
@@ -48,11 +48,11 @@
end
center_x = location_x + (size_width / 2.0)
center_y = location_y + (size_height / 2.0)
- w = $driver.window_size
+ w = driver.window_size
OpenStruct.new(x: "#{center_x} / #{w.width.to_f}",
y: "#{center_y} / #{w.height.to_f}")
end
end
end # module Common
@@ -127,12 +127,17 @@
# non-standard command hash
# It's important to output this for debugging problems.
# for example invalid JSON will not be a Hash
Appium::Logger.ap_info command_hash
end
- delay = $driver.global_webdriver_http_sleep
- sleep delay if !delay.nil? && delay > 0
+
+ if !$driver.nil? && $driver.global_webdriver_http_sleep
+ warn '[DEPRECATION] global_webdriver_http_sleep will be removed. Please arrange with timeout.'
+
+ delay = $driver.global_webdriver_http_sleep
+ sleep delay if delay > 0
+ end
# Appium::Logger.info "verb: #{verb}, path #{path}, command_hash #{command_hash.to_json}"
http.call(verb, path, command_hash)
end # def
end # class
end
@@ -166,9 +171,20 @@
end
def patch_remote_driver_commands
Selenium::WebDriver::Remote::OSS::Bridge.class_eval do
def commands(command)
- ::Appium::Driver::Commands::COMMAND[command]
+ ::Appium::Driver::Commands::COMMANDS_EXTEND_OSS[command]
+ end
+ end
+
+ Selenium::WebDriver::Remote::W3C::Bridge.class_eval do
+ def commands(command)
+ case command
+ when :status, :is_element_displayed
+ ::Appium::Driver::Commands::COMMANDS_EXTEND_OSS[command]
+ else
+ ::Appium::Driver::Commands::COMMANDS_EXTEND_W3C[command]
+ end
end
end
end