How to fix “invalid argument: invalid 'expiry'” in Selenium when adding cookies to a chromedriver?

后端 未结 4 813
伪装坚强ぢ
伪装坚强ぢ 2020-12-15 10:14

I\'m trying to add cookies to a browser, but getting the following error:

Message: invalid argument: invalid \'expiry\' (Session info: chrome=75.0.3770.90)

T

4条回答
  •  既然无缘
    2020-12-15 10:29

    In my case, the previous answer did not work. I had to remove the expire key from the object.

     for cookie in pickle.load(open(PATH, "rb")):
         if 'expiry' in cookie:
             del cookie['expiry']
    
         self.driver.add_cookie(cookie)
    

    This happens if you previously pickled the cookies directly as they're returned from the driver, like so:

    pickle.dump(browser.get_cookies(), open(PATH, "wb"))
    

提交回复
热议问题