lib/appium_lib/common/patch.rb in appium_lib-4.1.0 vs lib/appium_lib/common/patch.rb in appium_lib-5.0.0
- old
+ new
@@ -1,5 +1,7 @@
+require_relative 'version'
+
module Appium
module Common
# Implement useful features for element.
class Selenium::WebDriver::Element
# Note: For testing .text should be used over value, and name.
@@ -87,10 +89,11 @@
path_str.length <= 0 || path_str[0] == '/'
path_match = path.match /.*\h{8}-?\h{4}-?\h{4}-?\h{4}-?\h{12}/
path_str = path.sub(path_match[0], '') unless path_match.nil?
puts "#{verb} #{path_str}"
+
# must check to see if command_hash is a hash. sometimes it's not.
if command_hash.is_a?(Hash) && !command_hash.empty?
print_command = command_hash.clone
print_command.delete :args if print_command[:args] == []
@@ -102,10 +105,14 @@
# avoid backslash escape quotes in strings. "\"a\"" => "a"
puts print_command.ai.gsub('\"', '"')
else
ap print_command
end
+ else # non-standard command hash
+ # It's important to output this for debugging problems.
+ # for example invalid JSON will not be a Hash
+ ap command_hash if command_hash
end
delay = $driver.global_webdriver_http_sleep
sleep delay if !delay.nil? && delay > 0
# puts "verb: #{verb}, path #{path}, command_hash #{command_hash.to_json}"
http.call verb, path, command_hash
@@ -129,6 +136,11 @@
msg = "unknown error, status=#{status}: #{val.inspect}"
end
msg
end
+end
+
+class Selenium::WebDriver::Remote::Http::Common
+ remove_const :DEFAULT_HEADERS if defined? DEFAULT_HEADERS
+ DEFAULT_HEADERS = { 'Accept' => CONTENT_TYPE, 'User-Agent' => "appium/ruby_lib/#{::Appium::VERSION}" }
end
\ No newline at end of file