Skip to content
Advertisement

I can’t add cookies on python selenium webdriver

I’m trying to enter a page and then add cookies on it, but it returns an error and I don’t know why. I did it exactly like is written on the selenium docs, and here is the code i used:

JavaScript

And it returns selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: missing 'name'.
I already thought that it could be the code trying to add cookies before the page is totally loaded, but it isn’t. I put a time.sleep(30) between get and add_cookie and it returned the same exception.

Advertisement

Answer

Actually it was just a wrong usage of add_cookie(). The right way to send cookies is like this:

JavaScript

My error was using directly the cookie name + the value, and not with the dict template.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement