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.
9 10 11 |
# File 'lib/selenium/webdriver/common/options.rb', line 9 def initialize(bridge) @bridge = bridge end |
Instance Method Details
#add_cookie(opts = {}) ⇒ Object
Add a cookie to the browser
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/selenium/webdriver/common/options.rb', line 26 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
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/selenium/webdriver/common/options.rb', line 76 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
48 49 50 |
# File 'lib/selenium/webdriver/common/options.rb', line 48 def (name) .find { |c| c[:name] == name } end |
#delete_all_cookies ⇒ Object
Delete all cookies
66 67 68 |
# File 'lib/selenium/webdriver/common/options.rb', line 66 def @bridge.deleteAllCookies end |
#delete_cookie(name) ⇒ Object
Delete the cookie with the given name
58 59 60 |
# File 'lib/selenium/webdriver/common/options.rb', line 58 def (name) @bridge.deleteCookie name end |
#logs ⇒ Object
97 98 99 |
# File 'lib/selenium/webdriver/common/options.rb', line 97 def logs @logs ||= Logs.new(@bridge) end |