Class: Selenium::WebDriver::Manager
Relationships & Source Files | |
Inherits: | Object |
Defined in: | rb/lib/selenium/webdriver/common/manager.rb |
Constant Summary
-
SECONDS_PER_DAY =
# File 'rb/lib/selenium/webdriver/common/manager.rb', line 11386_400.0
Class Method Summary
- .new(bridge) ⇒ Manager constructor Internal use only Internal use only
Instance Method Summary
-
#add_cookie(opts = {})
Add a cookie to the browser.
-
#all_cookies ⇒ Array<Hash>
Get all cookies.
-
#cookie_named(name) ⇒ Hash?
Get the cookie with the given name.
-
#delete_all_cookies
Delete all cookies.
-
#delete_cookie(name)
Delete the cookie with the given name.
- #timeouts
- #window
- #convert_cookie(cookie) private
- #datetime_at(int) private
- #seconds_from(obj) private
- #strip_port(str) private
Constructor Details
.new(bridge) ⇒ Manager
This method is for internal use only.
# File 'rb/lib/selenium/webdriver/common/manager.rb', line 27
def initialize(bridge) @bridge = bridge end
Instance Method Details
#add_cookie(opts = {})
Add a cookie to the browser
# File 'rb/lib/selenium/webdriver/common/manager.rb', line 45
def (opts = {}) raise ArgumentError, 'name is required' unless opts[:name] raise ArgumentError, 'value is required' unless opts[:value] # NOTE: This is required because of https://bugs.chromium.org/p/chromedriver/issues/detail?id=3732 opts[:secure] ||= false same_site = opts.delete(:same_site) opts[:sameSite] = same_site if same_site http_only = opts.delete(:http_only) opts[:httpOnly] = http_only if http_only obj = opts.delete(:expires) opts[:expiry] = seconds_from(obj).to_int if obj @bridge. opts end
#all_cookies ⇒ Array
<Hash
>
Get all cookies
# File 'rb/lib/selenium/webdriver/common/manager.rb', line 99
def @bridge. .map { || ( ) } end
#convert_cookie(cookie) (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/manager.rb', line 136
def ( ) { name: ['name'], value: ['value'], path: ['path'], domain: ['domain'] && strip_port( ['domain']), expires: ['expiry'] && datetime_at( ['expiry']), same_site: ['sameSite'], http_only: ['httpOnly'], secure: ['secure'] } end
#cookie_named(name) ⇒ Hash
?
Get the cookie with the given name
# File 'rb/lib/selenium/webdriver/common/manager.rb', line 71
def (name) (@bridge. (name)) end
#datetime_at(int) (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/manager.rb', line 115
def datetime_at(int) DateTime.civil(1970) + (int / SECONDS_PER_DAY) end
#delete_all_cookies
Delete all cookies
# File 'rb/lib/selenium/webdriver/common/manager.rb', line 89
def @bridge. end
#delete_cookie(name)
Delete the cookie with the given name
# File 'rb/lib/selenium/webdriver/common/manager.rb', line 81
def (name) @bridge. name end
#seconds_from(obj) (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/manager.rb', line 119
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) (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/common/manager.rb', line 132
def strip_port(str) str.split(':', 2).first end