Details: For our test procedures, we want to read the cookies of a website, manipulate the cookie and read it again.

We want to test if this is possible at all to avoid a security gap.

We use for our test procedures:

Selenium - latest version Python - Latest version And several other Python packages.

Question: Can I use Selenium to read the cookies, write them back after manipulation?

  • Something like this? stackoverflow.com/questions/15058462/… – pavelsaman Jan 20 at 14:22
  • It goes that way, but only partially. I am also more concerned about a manipulation of the cookie, error message which I would like to have afterwards, but then as a positive test. So it's a bit different ;) – Mornon Jan 20 at 14:30
  • I'm a bit confused about what you want to achieve. But an answer to your question in the title is simply yes :) If you need a certain flow after you manipulate the cookies, well, you'd need to describe that a bit more, at least I don't fully get it from your current description. – pavelsaman Jan 20 at 16:23

I've never done with with Python, but, have a few times with C#. I know you won't be able to copy/paste this, but, will maybe help point you in the right direction

        string cookieNameString = _driver.Manage().Cookies.GetCookieNamed("actualCookieName").Value;
        cookieNameString = "my new cookie value";
        Cookie actualCookieName = new Cookie("actualCookieName", cookieNameString);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.