I want to reuse a whatsapp web session via Python 3 and Selenium on Chromedriver.
For which I need to grab the localstorage of an existing session and set it to the new browser instance before opening whatsapp web again.
I do so, on a logged in session:
cacho="";
for (var i = 0; i < localStorage.length; i++){
cacho+="localStorage.setItem('"+localStorage.key(i)+"', '"+localStorage.getItem(localStorage.key(i))+"');"
}
alert(cacho)
With driver.execute_script(), and I get the working localstorage data.
I copy the whole thing (a few javascript lines) and then, when opening a new browser instance, I do:
driver.execute_script(the_whole_thing)
driver.get(url)
But the session is not alive.
What am I missing here?