You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#* capturing default cookies created by the browser
29
+
cookies=driver.get_cookies()
30
+
print ("size of cookies : ", len(cookies)) #5
31
+
32
+
33
+
# for c in cookies:
34
+
# print(c) #* print all cookies
35
+
# print(c.get('name')) #* print names of cookies
36
+
# print(c.get('name'), ":", c.get('value')) #* print names and value of cookies
37
+
38
+
#! adding new cookie or user defined cookie to the browser.
39
+
driver.add_cookie({"name" : "MyCookie", "value" : "FY777"}) #* you can add as many attributes you want
40
+
cookies=driver.get_cookies()
41
+
print ("size of cookies after adding a cookie : ", len(cookies)) #* sometimes after creating a cookie size remain the same. that means your app or site is not allowing you to create a cookie
42
+
43
+
#! deleting a cookie
44
+
driver.delete_cookie("MyCookie")
45
+
cookies=driver.get_cookies()
46
+
print ("size of cookies after deleting a cookie : ", len(cookies))
47
+
48
+
driver.delete_all_cookies()
49
+
cookies=driver.get_cookies()
50
+
print ("size of cookies after deleting all cookies : ", len(cookies))
0 commit comments