Skip to content

Commit 8fe051d

Browse files
aguspesandeepsuryaprasad
authored andcommitted
[rb] Add tests for the cookie named, and updates type (SeleniumHQ#14843)
* add tests for the cookie named, and updates type * update gemfile lock
1 parent 4977e7c commit 8fe051d

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

rb/Gemfile.lock

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PATH
1313
GEM
1414
remote: https://rubygems.org/
1515
specs:
16-
activesupport (8.0.0)
16+
activesupport (7.2.2)
1717
base64
1818
benchmark (>= 0.3)
1919
bigdecimal
@@ -25,7 +25,6 @@ GEM
2525
minitest (>= 5.1)
2626
securerandom (>= 0.3)
2727
tzinfo (~> 2.0, >= 2.0.5)
28-
uri (>= 0.13.1)
2928
addressable (2.8.7)
3029
public_suffix (>= 2.0.2, < 7.0)
3130
ast (2.4.2)
@@ -162,7 +161,6 @@ GEM
162161
tzinfo (2.0.6)
163162
concurrent-ruby (~> 1.0)
164163
unicode-display_width (2.6.0)
165-
uri (1.0.2)
166164
webmock (3.24.0)
167165
addressable (>= 2.8.0)
168166
crack (>= 0.3.2)

rb/lib/selenium/webdriver/common/manager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def add_cookie(opts = {})
6565
# Get the cookie with the given name
6666
#
6767
# @param [String] name the name of the cookie
68-
# @return [Hash, nil] the cookie, or nil if it wasn't found.
68+
# @return [Hash, nil] the cookie, or throws a NoSuchCookieError if it wasn't found.
6969
#
7070

7171
def cookie_named(name)

rb/sig/lib/selenium/webdriver/common/manager.rbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Selenium
1111

1212
def add_cookie: (?Hash[Symbol, untyped] opts) -> void
1313

14-
def cookie_named: (String name) -> Hash[Symbol, untyped]
14+
def cookie_named: (String name) -> (Hash[Symbol, untyped] | Error::NoSuchCookieError)
1515

1616
def delete_cookie: (String name) -> String
1717

@@ -33,7 +33,7 @@ module Selenium
3333

3434
def strip_port: (String str) -> String?
3535

36-
def convert_cookie: (Hash[String, untyped] cookie) -> Hash[Symbol, untyped]
36+
def convert_cookie: (String) -> (Hash[Symbol, untyped] | Error::NoSuchCookieError)
3737
end
3838
end
3939
end

rb/spec/integration/selenium/webdriver/manager_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ module WebDriver
248248
driver.manage.delete_all_cookies
249249
expect(driver.manage.all_cookies).to be_empty
250250
end
251+
252+
it 'throws error when fetching non-existent cookie' do
253+
expect { driver.manage.cookie_named('non-existent') }
254+
.to raise_exception(Error::NoSuchCookieError)
255+
end
251256
end
252257
end # Options
253258
end # WebDriver

0 commit comments

Comments
 (0)