class Selenium::WebDriver::Options

Constants

SECONDS_PER_DAY

Public Class Methods

new(bridge) click to toggle source

@api private

# File lib/selenium/webdriver/common/options.rb, line 9
def initialize(bridge)
  @bridge = bridge
end

Public Instance Methods

all_cookies() click to toggle source

Get all cookies

@return [Array<Hash>] list of cookies

# File lib/selenium/webdriver/common/options.rb, line 76
def all_cookies
  @bridge.getAllCookies.map do |cookie|
    {
      :name    => cookie["name"],
      :value   => cookie["value"],
      :path    => cookie["path"],
      :domain  => cookie["domain"] && strip_port(cookie["domain"]),
      :expires => cookie["expiry"] && datetime_at(cookie['expiry']),
      :secure  => cookie["secure"]
    }
  end
end
delete_all_cookies() click to toggle source

Delete all cookies

# File lib/selenium/webdriver/common/options.rb, line 66
def delete_all_cookies
  @bridge.deleteAllCookies
end
logs() click to toggle source

@api beta This API may be changed or removed in a future release.

# File lib/selenium/webdriver/common/options.rb, line 97
def logs
  @logs ||= Logs.new(@bridge)
end
timeouts() click to toggle source
# File lib/selenium/webdriver/common/options.rb, line 89
def timeouts
  @timeouts ||= Timeouts.new(@bridge)
end
window() click to toggle source

@api beta This API may be changed or removed in a future release.

# File lib/selenium/webdriver/common/options.rb, line 105
def window
  @window ||= Window.new(@bridge)
end

Private Instance Methods

datetime_at(int) click to toggle source
# File lib/selenium/webdriver/common/options.rb, line 113
def datetime_at(int)
  DateTime.civil(1970) + (int / SECONDS_PER_DAY)
end
seconds_from(obj) click to toggle source
# File lib/selenium/webdriver/common/options.rb, line 117
def seconds_from(obj)
  case obj
  when Time
    obj.to_f
  when DateTime
    (obj - DateTime.civil(1970)) * SECONDS_PER_DAY
  when Numeric
    obj
  else
    raise ArgumentError, "invalid value for expiration date: #{obj.inspect}"
  end
end
strip_port(str) click to toggle source
# File lib/selenium/webdriver/common/options.rb, line 130
def strip_port(str)
  str.split(":", 2).first
end