Method: Selenium::WebDriver::Options#as_json

Defined in:
lib/selenium/webdriver/common/options.rb

#as_jsonObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/selenium/webdriver/common/options.rb', line 116

def as_json(*)
  options = @options.dup

  downloads = options.delete(:enable_downloads)
  options['se:downloadsEnabled'] = downloads unless downloads.nil?
  w3c_options = process_w3c_options(options)

  browser_options = self.class::CAPABILITIES.each_with_object({}) do |(capability_alias, capability_name), hash|
    capability_value = options.delete(capability_alias)
    hash[capability_name] = capability_value unless capability_value.nil?
  end

  raise Error::WebDriverError, "These options are not w3c compliant: #{options}" unless options.empty?

  browser_options = {self.class::KEY => browser_options} if defined?(self.class::KEY)

  process_browser_options(browser_options)
  generate_as_json(w3c_options.merge(browser_options))
end