title: Python and Selenium - Reuse a whatsapp web session
body: <p>I want to reuse a whatsapp web session via Python 3 and Selenium on Chromedriver.</p>
  
  <p>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.</p>
  
  <p>I do so, on a <strong>logged in</strong> session:</p>
  
  <pre><code>cacho="";
  for (var i = 0; i &lt; localStorage.length; i++){
  cacho+="localStorage.setItem('"+localStorage.key(i)+"', '"+localStorage.getItem(localStorage.key(i))+"');"
  }
  alert(cacho)
  </code></pre>
  
  <p>With <em>driver.execute_script()</em>, and I get the working localstorage data.</p>
  
  <p>I copy the whole thing (a few javascript lines) and then, when opening a new browser instance, I do:</p>
  
  <pre><code>driver.execute_script(the_whole_thing)
  driver.get(url)
  </code></pre>
  
  <p>But the session is not alive.</p>
  
  <p>What am I missing here?</p>