Skip to content

Commit ebf3c35

Browse files
authored
Update README.md
1 parent f73980f commit ebf3c35

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,25 @@
1212
```
1313
install maven
1414
```
15-
15+
### Managing cookies
16+
17+
To manage cookies, the following code can be used:
18+
```java
19+
driver.manage().addCookie(new Cookie("cookieName", "lambdatest")); // Creates and adds the cookie
20+
21+
Set<Cookie> cookiesSet = driver.manage().getCookies(); // Returns the List of all Cookies
22+
23+
for (Cookie itemCookie : cookiesSet) {
24+
System.out.println((itemCookie.getName() + ";" + itemCookie.getValue() + ";" + itemCookie.getDomain() + ";"
25+
+ itemCookie.getPath() + ";" + itemCookie.getExpiry() + ";" + itemCookie.isSecure()));
26+
}
27+
28+
driver.manage().getCookieNamed("cookieName"); // Returns the specific cookie according to name
29+
30+
driver.manage().deleteCookie(driver.manage().getCookieNamed("cookieName")); // Deletes the specific cookie
31+
driver.manage().deleteCookieNamed("cookieName"); // Deletes the specific cookie according to the Name
32+
driver.manage().deleteAllCookies(); // Deletes all the cookies
33+
```
1634
### Run your First Test
1735
1. Clone the Java-Selenium-Sample repository.
1836
```

0 commit comments

Comments
 (0)