I understand that if I want to delete a cookie through Selenium I should do the next:
this.getDriverProvider().get().manage().deleteCookieNamed("cookie");
But, when I created this cookie I set:
Cookie cookie = new Cookie("name=cookie", "max_age=1200");
I found that if I want to delete this cookie, I have to pass name=cookie and not cookie alone. So, I don’t understand how these pairs values are used then.
Please, can somebody help me?
Thanks,
Sarang
When you create a cookie, you’re passing
name=cookieas its name. Constructor parameters are ordered and are mapped to its corresponding attribute so you don’t have to specify that the first parameter will be the cookie’s name.If you were to add a value AFTER the creation, you invoke a method that will set the value you use as the value of the key associated to the method. For example:
And then, when you invoke the getName() method you’ll get the value associated to the key name, passed on the corresponding constructor. In your case is “name=cookie” and in my case is just “name”.
If you feel like, you can check the documentation.