marathon-core/ruby-selenium-webdriver/src/main/resources/gems/selenium-webdriver-3.6.0/lib/selenium/webdriver/remote/w3c/capabilities.rb
#
# Creates W3C compliant capabilities from OSS ones.
# @param oss_capabilities [Hash, Remote::Capabilities]
#
Creates W3C compliant capabilities from OSS ones.
Creates W3C compliant capabilities from OSS ones .
def from_oss(oss_capabilities)
              w3c_capabilities = new
              oss_capabilities = oss_capabilities.__send__(:capabilities) unless oss_capabilities.is_a?(Hash)
              oss_capabilities.each do |name, value|
                next if value.nil?
                next if value.is_a?(String) && value.empty?
                capability_name = name.to_s
                snake_cased_capability_names = KNOWN.map(&:to_s)
                camel_cased_capability_names = snake_cased_capability_names.map(&w3c_capabilities.method(:camel_case))
                next unless snake_cased_capability_names.include?(capability_name) ||
                            camel_cased_capability_names.include?(capability_name) ||
                            capability_name.match(EXTENSION_CAPABILITY_PATTERN)
                w3c_capabilities[name] = value
              end
               TODO (alex): Refactor this whole method into converter class.
              firefox_options = oss_capabilities['firefoxOptions'] || oss_capabilities['firefox_options'] || oss_capabilities[:firefox_options]
              firefox_profile = oss_capabilities['firefox_profile'] || oss_capabilities[:firefox_profile]
              firefox_binary  = oss_capabilities['firefox_binary'] || oss_capabilities[:firefox_binary]
              if firefox_profile && firefox_options
                second_profile = firefox_options['profile'] || firefox_options[:profile]
                if second_profile && firefox_profile != second_profile
                  raise Error::WebDriverError, 'You cannot pass 2 different Firefox profiles'
                end
              end
              if firefox_options || firefox_profile || firefox_binary
                options = WebDriver::Firefox::Options.new(firefox_options || {})
                options.binary = firefox_binary if firefox_binary
                options.profile = firefox_profile if firefox_profile
                w3c_capabilities.merge!(options.as_json)
              end
              w3c_capabilities
            end
def from_oss ( oss_capabilities ) w3c_capabilities = new oss_capabilities = oss_capabilities . __send__ ( :capabilities ) unless oss_capabilities . is_a? ( Hash ) oss_capabilities . each do | name , value | next if value . nil? next if value . is_a? ( String ) && value . empty? capability_name = name . to_s snake_cased_capability_names = KNOWN . map ( & :to_s ) camel_cased_capability_names = snake_cased_capability_names . map ( & w3c_capabilities . method ( :camel_case ) ) next unless snake_cased_capability_names . include? ( capability_name ) || camel_cased_capability_names . include? ( capability_name ) || capability_name . match ( EXTENSION_CAPABILITY_PATTERN ) w3c_capabilities [ name ] = value end firefox_options = oss_capabilities [ 'firefoxOptions' ] || oss_capabilities [ 'firefox_options' ] || oss_capabilities [ :firefox_options ] firefox_profile = oss_capabilities [ 'firefox_profile' ] || oss_capabilities [ :firefox_profile ] firefox_binary = oss_capabilities [ 'firefox_binary' ] || oss_capabilities [ :firefox_binary ] if firefox_profile && firefox_options second_profile = firefox_options [ 'profile' ] || firefox_options [ :profile ] if second_profile && firefox_profile != second_profile raise Error :: WebDriverError , 'You cannot pass 2 different Firefox profiles' end end if firefox_options || firefox_profile || firefox_binary options = WebDriver :: Firefox :: Options . new ( firefox_options || { } ) options . binary = firefox_binary if firefox_binary options . profile = firefox_profile if firefox_profile w3c_capabilities . merge! ( options . as_json ) end w3c_capabilities end
Creates W3C compliant capabilities from OSS ones.
Creates W3C compliant capabilities from OSS ones .
# TODO (alex): make capabilities enumerable? # User can pass :firefox_options or :firefox_profile. # # TODO (alex): Refactor this whole method into converter class.
oss_capabilities
None