function driver.delete_all_cookies() in selenium python doesn't delete all cookies

青春壹個敷衍的年華 提交于 2021-01-29 07:26:01

问题


I'm trying to delete all cookies from browser and then checking that no cookies remained. after that I ran my code I saw that still, some cookies remained... what's the problem? thanks

from selenium import webdriver
driver = webdriver.Chrome(executable_path= 
"C:\\Chrome\\chromedriver.exe")
driver.get("http://www.walla.co.il")
driver.delete_all_cookies()
lst = driver.get_cookies()
for cookie in lst:
    print(cookie)

回答1:


I think this problem is more related to the load time from the website. I just try your code adding a time.sleep(5) and the cookies are deleted correctly. Probably when you are trying to delete the cookies the page hasn't finished loading



来源:https://stackoverflow.com/questions/56515085/function-driver-delete-all-cookies-in-selenium-python-doesnt-delete-all-cooki

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!