Skip to content

Commit 88d80ba

Browse files
committed
add tests for the cookie named, and updates type
1 parent dd8c914 commit 88d80ba

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

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)