We are using selenium 2.4 with a python client, and running the scripts on Firefox.
When doing delete_all_visible_cookies we are getting the exception:
ERROR: Command execution failure. Please search the user group at https://groups.google.com/forum/#!forum/selenium-users for error details from the log window. The error message is: malformed URI sequence
We realized it happens when we have a cookie from a third-party (so we can’t change it) that causes the problem. We asked about it here in the past and there is an open bug of Selenium for this problem, but it wasn’t fixed yet.
To overcome this problem in the meanwhile we deleted the problematic cookie separately using delete_cookie before doing delete_all_visible_cookies. However, in Selenium 2 we are getting this error also for delete_cookie.
We thought it may be because of the cookie’s value (something like: WSS_GW=V1z%X%X^^^@C@) so we tried to override it and set it to 0 before deleting the cookie. Then we got the error:
ERROR: Couldn’t delete cookie WSS_GW.
The only explanation I found in the web for this error message is:
deleteAllVisibleCookies fails if a cookie name contains % character
but we have other cookies that contain _ in their name and everything is working fine.
Any idea what can be the problem or how we can overcome it?
ok, we found the 2 problems we have here:
The cookie value is problematic, therefore we got the ‘malformed URI sequence’ error. To solve this problem I set the cookie value to 0 using create_cookie(), before deleting the cookies.
There are 2 cookie with the same name and value, but with different domains: one with ‘domain.com’ and one with ‘a.domain.com’ (and the script opened http://b.domain.com). I guess that somehow Selenium saw both of the cookies, and after deleting one it still saw a cookie with the same name, so we got the ‘Couldn’t delete cookie’ error. To solve that, (after I changes the value of all these cookies) I deleted the cookie with the domain ‘domain.com’ using delete_cookie() without the recurse parameter, so when I call delete_all_visible_cookies() it was just one cookie with this name.
To summarize, what I did is: