1

I use with reqeust.session and reqeust post to send some data to the server. I want to transfer the session from the reqeust to selenium and after that open the selenium browser and continue to use. Can I do it?

If there is option to load selenium browser and send POST reqeust and after that countiue use with the selenium browser its also option for me.

thanks

  • The session should be identified by a cookie, so you should be able to get cookie from the requests response https://stackoverflow.com/a/31555440/202168 and add it to the subsequent selenium requests https://stackoverflow.com/a/15058521/202168 – Anentropic Jun 16 '22 at 08:51
  • thank you, I get the cookie from the reqeust session and its get like this ", , , ]>" and the selenium load cookie need to be json... there is option to convert it? – Segev Solomon Jun 16 '22 at 09:39
  • So there are several cookies in the "cookie jar"... you may need to add all of them or just a subset. See https://requests.readthedocs.io/en/latest/api/?highlight=cookies#cookies – Anentropic Jun 16 '22 at 10:02
  • not a good idea to post actual session cookies here... (hopefully that's not the case...) – pcalkins Jun 16 '22 at 18:42
  • easiest way to do this would be to set the webdriver to use a profile that has already logged in. This may or may not contain session cookies. It really depends on the site's implementation. – pcalkins Jun 16 '22 at 18:43

0 Answers0