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.
26 27 28 |
# File 'lib/selenium/webdriver/common/options.rb', line 26 def initialize(bridge) @bridge = bridge end |
Instance Method Details
#add_cookie(opts = {}) ⇒ Object
Add a cookie to the browser
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/selenium/webdriver/common/options.rb', line 43 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
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/selenium/webdriver/common/options.rb', line 93 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
65 66 67 |
# File 'lib/selenium/webdriver/common/options.rb', line 65 def (name) .find { |c| c[:name] == name } end |
#delete_all_cookies ⇒ Object
Delete all cookies
83 84 85 |
# File 'lib/selenium/webdriver/common/options.rb', line 83 def @bridge.deleteAllCookies end |
#delete_cookie(name) ⇒ Object
Delete the cookie with the given name
75 76 77 |
# File 'lib/selenium/webdriver/common/options.rb', line 75 def (name) @bridge.deleteCookie name end |
#logs ⇒ Object
114 115 116 |
# File 'lib/selenium/webdriver/common/options.rb', line 114 def logs @logs ||= Logs.new(@bridge) end |
#timeouts ⇒ Object
106 107 108 |
# File 'lib/selenium/webdriver/common/options.rb', line 106 def timeouts @timeouts ||= Timeouts.new(@bridge) end |
#window ⇒ Object
122 123 124 |
# File 'lib/selenium/webdriver/common/options.rb', line 122 def window @window ||= Window.new(@bridge) end |