Per below, I\'m not sure how to troubleshoot this pretty simple usage scenario.
I have script (that I run about once a month) that functionally does the identical th
The answer of Florent B. works for me as well, just want to put it into the right place.
browser.cookies.add
needs to be called after some browser.visit(...)
see Florent's comment:
The method browser.cookies.add is bound to the current domain which is undefined in your example. You need to set the domain first with driver.get('http://...')
you should open the url first, and load the cookies, then you can open the next url with cookies.you can also open like that if you want open the same url:
driver = webdriver.Chrome(executable_path=r'X:\home\xxx\chromedriver.exe')
cookies = pickle.load(open("cookies.pkl", "rb"))
driver.get("https://www.douban.com/")
for cookie in cookies:
driver.add_cookie(cookie)
driver.get("https://www.douban.com/")
hope this helps