Skip to content

Commit 7ca35e3

Browse files
rpallavisharmasandeepsuryaprasad
authored andcommitted
modified delete cookie added code and test (SeleniumHQ#15386)
1 parent c636b3b commit 7ca35e3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

rb/lib/selenium/webdriver/remote/bridge.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ def add_cookie(cookie)
385385
end
386386

387387
def delete_cookie(name)
388+
raise ArgumentError, 'Cookie name cannot be null or empty' if name.nil? || name.strip.empty?
389+
388390
execute :delete_cookie, name: name
389391
end
390392

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ module WebDriver
237237

238238
it 'deletes one' do
239239
driver.manage.add_cookie name: 'foo', value: 'bar'
240-
241240
driver.manage.delete_cookie('foo')
242241
expect(driver.manage.all_cookies.find { |c| c[:name] == 'foo' }).to be_nil
243242
end
@@ -253,6 +252,16 @@ module WebDriver
253252
expect { driver.manage.cookie_named('non-existent') }
254253
.to raise_exception(Error::NoSuchCookieError)
255254
end
255+
256+
it 'throws an error when cookie name is an empty string' do
257+
expect { driver.manage.delete_cookie('') }
258+
.to raise_error(ArgumentError, /Cookie name cannot be null or empty/)
259+
end
260+
261+
it 'throws an error when cookie name is a nil string' do
262+
expect { driver.manage.delete_cookie(nil) }
263+
.to raise_error(ArgumentError, /Cookie name cannot be null or empty/)
264+
end
256265
end
257266
end # Options
258267
end # WebDriver

0 commit comments

Comments
 (0)