selenium cookies code example

Example 1: how to handle cookies in selenium

There are several ways to handle cookies 
driver.manage().getCookies(); 		    // Return The List of all Cookies
driver.manage().getCookieNamed(arg0); //Return specific cookie according to name
driver.manage().addCookie(arg0); 	 //Create and add the cookie
driver.manage().deleteCookie(arg0);  // Delete specific cookie
driver.manage().deleteCookieNamed(arg0);// Delete specific cookie according Name
driver.manage().deleteAllCookies();   // Delete all cookies

Example 2: how to handle cookies in selenium

There are several ways to handle cookies 
driver.manage().getCookies(); 		    // Return The List of all Cookies
driver.manage().getCookieNamed(arg0); //Return specific cookie according to name
driver.manage().addCookie(arg0); 	 //Create and add the cookie
driver.manage().deleteCookie(arg0);  // Delete specific cookie
driver.manage().deleteCookieNamed(arg0);// Delete specific cookie according Name
driver.manage().deleteAllCookies();   // Delete all cookies

Example 3: how to handle cookie

To handle cookie in postman there is a button
called cookie to give us a way to add cookie
to certain domain by providing key+value pair
Once added any request sent to the same domain,
can access that cookie. We can also access to
the cookie in test tab.

pm.test('the "abc" cookie has correct value', function () {
    pm.expect(pm.cookies.toObject()).to.have.property('abc', 'AWESOME');
});

pm.test('the "Motto" cookie has correct value', function () {
    pm.expect(pm.cookies.toObject()).to.have.property('Motto', 'Hold your horse');
});