0
I’m doing tests using the web Whatsapp, so every time I run Selenium, read the qr code and start the tests, and I have to do this every time, I’d like to know if there’s a way to save the state of the browser, save the session, some way to start the browser without the need to read the qr code again.
I’m using python for this.
I tried this way, but I can’t save the cookies:
Saving the file:
import pickle
import selenium.webdriver
driver = selenium.webdriver.Firefox()
driver.get("http://www.google.com")
pickle.dump( driver.get_cookies() , open("cookies.pkl","wb"))
Recovering the File:
import pickle
import selenium.webdriver
driver = selenium.webdriver.Firefox()
driver.get("http://www.google.com")
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
driver.add_cookie(cookie)
I use pprint to show the driver.get_cookies() and it returns an empty array, I thought it might be because it picks up before loading cookies,.