[rb] explicitly handle all w3c required capabilities from session creation return value
@@ -128,11 +128,10 @@ module Selenium
data = data.dup
caps = new
- caps.browser_name = data.delete('browserName') if data.key?('browserName')
- caps.browser_version = data.delete('browserVersion') if data.key?('browserVersion')
- caps.platform_name = data.delete('platformName') if data.key?('platformName')
- caps.accept_insecure_certs = data.delete('acceptInsecureCerts') if data.key?('acceptInsecureCerts')
- caps.page_load_strategy = data.delete('pageLoadStrategy') if data.key?('pageLoadStrategy')
+ (KNOWN - %i[timeouts proxy]).each do |cap|
+ data_value = camel_case(cap)
+ caps[cap] = data.delete(data_value) if data.key?(data_value)
+ end
process_timeouts(caps, data.delete('timeouts'))
@@ -142,7 +141,9 @@ module Selenium
end
# Remote Server Specific
- caps[:remote_session_id] = data.delete('webdriver.remote.sessionid') if data.key?('webdriver.remote.sessionid')
+ if data.key?('webdriver.remote.sessionid')
+ caps[:remote_session_id] = data.delete('webdriver.remote.sessionid')
+ end
# any remaining pairs will be added as is, with no conversion
caps.merge!(data)
@@ -150,6 +151,10 @@ module Selenium
caps
end
+ def camel_case(str_or_sym)
+ str_or_sym.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
+ end
+
private
def process_timeouts(caps, timeouts)
@@ -232,7 +237,7 @@ module Selenium
when String
hash[key.to_s] = value
when Symbol
- hash[camel_case(key.to_s)] = value
+ hash[self.class.camel_case(key)] = value
else
raise TypeError, "expected String or Symbol, got #{key.inspect}:#{key.class} / #{value.inspect}"
end
@@ -256,13 +261,6 @@ module Selenium
protected
attr_reader :capabilities
-
- private
-
- def camel_case(str)
- str.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
- end
-
end # Capabilities
end # Remote
end # WebDriver
