Selenium Python save cookies, cache and sessions

Viewed 510

I have tried to save and load cookies but the website I was using didn't appreciated and log out my account...

I have found how to save and load the cookies in .pkl file :

pickle.dump(browser.get_cookies(), open("cookies.pkl","wb"))
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
    browser.add_cookie(cookie)

Maybe this is not enough for persistant sessions so I need to save cache and full sessions ?

I have found this in Selenium doc : GET_ALL_SESSIONS and GET_APP_CACHE. But it is used with remote driver, I don't understand what it is. I would like an easy way like I do with cookies...

How to save and load sessions and cache like I do with cookies please ?

0 Answers
Related