0

I collect cookies by selenium and store them in file, and then I'm trying to load them in not automated browser console by executing: document.cookie="key=value;...";.... Is there any other way?

GeorgePhysics
  • 71
  • 1
  • 8
  • Selenium has it's own methods for this (essentially the same as document.cookie...), but maybe you should explain a bit more about what you are trying to do here... are you trying to transfer cookies from one profile to another? – pcalkins Mar 06 '20 at 18:24
  • @pcalkins I want to collect cookies with selenium from automated session and then load them in not automated session – GeorgePhysics Mar 06 '20 at 19:23
  • You can set Selenium to use a certain profile. Then there's no need to store them as they will already be available to that profile after Selenium methods are run. – pcalkins Mar 06 '20 at 19:25
  • @pcalkins as far as I know, automated session does not save new cookies, you can only use old ones, which were got by user in not automated session – GeorgePhysics Mar 06 '20 at 19:28
  • hmm... looking into this further, you might be right. At least it used to be true for geckodriver that it would create a temporary copy of that profile and then remove it when the driver quit. I couldn't find out if Chromedriver did the same thing. I guess an option would be to copy the copied directory (overwriting the original profile) before quitting the driver? (Though I think it'll prevent copying some files because they will still be in use by the browser...) – pcalkins Mar 06 '20 at 20:15
  • Just a note that session-based cookies couldn't be re-used as they are tied to a session. The "remember me" types could and you should be able to just export them from the browser to import into another profile. (Each browser has their own methods for that... so export manually before the driver quits. Then import manually on your manual session.) – pcalkins Mar 06 '20 at 20:25

0 Answers0