public boolean verifyCookiePresentByName ( final String cookieName ) { Set < Cookie > cookies = driver . manage ( ) . getCookies ( ) ; for ( Cookie cookie : cookies ) { if ( cookie . getName ( ) . equals ( cookieName ) ) { LOG . info ( "Cookie: " + cookieName + " was found with value: " + cookie . getValue ( ) ) ; return true ; } } LOG . info ( "Cookie: " + cookieName + " NOT found!" ) ; return false ; }
Checks if the given cookie name exists in the current session . This method is also logging the result . The match is CASE SENSITIVE .