File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
lib/selenium/webdriver/remote
spec/integration/selenium/webdriver Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments