If I have a Selenium test which is currently logged in (with HTTP Authentication) to a particular website, how can I cause the remote browser to forget the current authentication so that I can log in as a different user (while remaining within the same test)?
A:
It depends how you are handling authentication.
If you are doing it via a cookie that gets checked server side you could do deleteCookie
or if you want to delete all of them on the page you could do deleteAllVisibleCookies
If you are keeping it within a JavaScript you could just use getEval
and delete whats in the variables.
AutomatedTester
2010-06-09 07:56:51
It's HTTP basic, so deleting cookies won't help unfortunately). Not quite sure what you're JavaScript approach is, but as I understand it, javascript can't modify the browser's HTTP Basic authentication cache.
Matt Sheppard
2010-06-11 06:58:48
+1
A:
Is this basic authentication? If it is, you can modify the basic auth header in your request to log in as a new user. You'll have to use Selenium server as a proxy in order to modify the request headers, however.
nirvdrum
2010-06-09 15:35:52
Yes - HTTP basic. I'm not quite sure how to go about what you suggest though.
Matt Sheppard
2010-06-11 06:57:22
Hi Matt,I finally got around to writing up an article on doing basic auth with Selenium. Hopefully it's helpful for you. You should be able to follow the technique and just change the Authorization header.http://mogotest.com/blog/2010/06/23/how-to-perform-basic-auth-in-selenium
nirvdrum
2010-06-24 18:48:16