Class: Selenium::WebDriver::Options
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Options
- Defined in:
- lib/selenium/webdriver/common/options.rb
Instance Method Summary collapse
-
#add_cookie(opts = {}) ⇒ Object
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 ⇒ Object
Delete all cookies.
-
#delete_cookie(name) ⇒ Object
Delete the cookie with the given name.
-
#initialize(bridge) ⇒ Options
constructor
private
A new instance of Options.
- #logs ⇒ Object
- #timeouts ⇒ Object
- #window ⇒ Object
Constructor Details
#initialize(bridge) ⇒ Options
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.
Returns a new instance of Options.
28 29 30 |
# File 'lib/selenium/webdriver/common/options.rb', line 28 def initialize(bridge) @bridge = bridge end |
Instance Method Details
#add_cookie(opts = {}) ⇒ Object
Add a cookie to the browser
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/selenium/webdriver/common/options.rb', line 45 def (opts = {}) raise ArgumentError, "name is required" unless opts[:name] raise ArgumentError, "value is required" unless opts[:value] opts[:path] ||= "/" opts[:secure] ||= false if obj = opts.delete(:expires) opts[:expiry] = seconds_from(obj) end @bridge.addCookie opts end |
#all_cookies ⇒ Array<Hash>
Get all cookies
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/selenium/webdriver/common/options.rb', line 95 def @bridge.getAllCookies.map do || { :name => ["name"], :value => ["value"], :path => ["path"], :domain => ["domain"] && strip_port(["domain"]), :expires => ["expiry"] && datetime_at(['expiry']), :secure => ["secure"] } end end |
#cookie_named(name) ⇒ Hash?
Get the cookie with the given name
67 68 69 |
# File 'lib/selenium/webdriver/common/options.rb', line 67 def (name) .find { |c| c[:name] == name } end |
#delete_all_cookies ⇒ Object
Delete all cookies
85 86 87 |
# File 'lib/selenium/webdriver/common/options.rb', line 85 def @bridge.deleteAllCookies end |
#delete_cookie(name) ⇒ Object
Delete the cookie with the given name
77 78 79 |
# File 'lib/selenium/webdriver/common/options.rb', line 77 def (name) @bridge.deleteCookie name end |
#logs ⇒ Object
116 117 118 |
# File 'lib/selenium/webdriver/common/options.rb', line 116 def logs @logs ||= Logs.new(@bridge) end |