title: Saving cookies to file and reusing in selenium web driver python -- Encoding list object
body: <p>I'm trying to read cookies from a session and save it in a file(I'm saving it as python pickle file) and use it next time rather than logging into the application again. It saves a lot of time. I'm using  Python 2.7.16rc1 and selenium web driver version 3.14.1.</p>
  
  <p>I have tried saving the cookie  which I get from <code>driver.get_cookies()</code>. The issue is that the cookies are saved in the pickled object with Unicode encoding with `u in it which is causing the issue while reading it and sending it back.</p>
  
  <p>I have tried to deal with the Unicode encoding option by reading the value in list one by one and applying UTF-8 encoding but getting a <code>AttributeError: 'dict' object has no attribute 'encode'</code></p>
  
  <p>The given below is the code to write the cookies to a pickle file</p>
  
  <p><code>pickle.dump(driver.get_cookies(), open("cookie.fkle","w"))</code></p>
  
  <p>The below codes reads it</p>
  
  <pre><code>import pickle
  
  cookies = pickle.load(open("cookie.fkle", "rb"))
  for cookie in cookies:
      print cookie 
  </code></pre>
  
  <p>I expect the output as below </p>
  
  <pre><code>{domain': google.com', name': lang', value': en', expiry': 1555427577, path': /', httpOnly': False, secure': False}
  {domain': .google.com', name': _ga', value': GA1.2.1834438095.1554822783', expiry': 1617894782, path': /', httpOnly': False, secure': False}
  {domain': .google.com', name': _gid', value': GA1.2.1839091575.1554822783', expiry': 1554909182, path': /', httpOnly': False, secure': False}
  {domain': .google.com', name': _gat_gtag_UA_60214108_5', value': 1', expiry': 1554822842, path': /', httpOnly': False, secure': False}
  </code></pre>
  
  <p>But I'm getting the output as:</p>
  
  <pre><code>{u'domain': u'google.com', u'name': u'lang', u'value': u'en', u'expiry': 1555427577, u'path': u'/', u'httpOnly': False, u'secure': False}
  {u'domain': u'.google.com', u'name': u'_ga', u'value': u'GA1.2.1834438095.1554822783', u'expiry': 1617894782, u'path': u'/', u'httpOnly': False, u'secure': False}
  {u'domain': u'.google.com', u'name': u'_gid', u'value': u'GA1.2.1839091575.1554822783', u'expiry': 1554909182, u'path': u'/', u'httpOnly': False, u'secure': False}
  {u'domain': u'.google.com', u'name': u'_gat_gtag_UA_60214108_5', u'value': u'1', u'expiry': 1554822842, u'path': u'/', u'httpOnly': False, u'secure': False}
  </code></pre>