File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
javascript/node/selenium-webdriver Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,12 @@ class Network {
7575
7676 async removeAuthenticationHandler ( id ) {
7777 await this . #init( )
78- this . #authHandlers. delete ( id )
78+
79+ if ( this . #authHandlers. has ( id ) ) {
80+ this . #authHandlers. delete ( id )
81+ } else {
82+ throw Error ( `Callback with id ${ id } not found` )
83+ }
7984 }
8085
8186 async clearAuthenticationHandlers ( ) {
Original file line number Diff line number Diff line change @@ -88,15 +88,12 @@ suite(
8888 }
8989 } )
9090
91- it ( 'can remove authentication handler that does not exist' , async function ( ) {
92- await driver . network ( ) . removeAuthenticationHandler ( 10 )
93-
91+ it ( 'throws an error when remove authentication handler that does not exist' , async function ( ) {
9492 try {
95- await driver . get ( Pages . basicAuth )
96- await driver . wait ( until . elementLocated ( By . css ( 'pre' ) ) )
97- assert . fail ( 'Page should not be loaded' )
93+ await driver . network ( ) . removeAuthenticationHandler ( 10 )
94+ assert . fail ( 'Expected error not thrown. Non-existent handler cannot be removed' )
9895 } catch ( e ) {
99- assert . strictEqual ( e . name , 'UnexpectedAlertOpenError ' )
96+ assert . strictEqual ( e . message , 'Callback with id 10 not found ' )
10097 }
10198 } )
10299
You can’t perform that action at this time.
0 commit comments