I'm trying to write an acceptance test using WatiN which checks that a user is redirected to the login page if they navigate to a page after their session times out. I'm using WatiN's IE
class for the browser, and trying the following:
// 1. Login
// 2. Do this:
Browser.ClearCookies();
Browser.ClearCache();
// 3. Navigate to a different page
But the user is always still logged in. Other info:
Browser.Eval("alert(document.cookie)");
in IE it alerts an empty stringGiven the above, I'm assuming this is a quirk with IE; any ideas how I can work around it?
It turns out this is due to the way IE deals with sessions and the deletion of authentication cookies; I found buried in this blog that you can clear authentication information in IE by making WatiN execute the following JavaScript:
Browser.Eval(@"document.execCommand(""ClearAuthenticationCache"", false);");
This works! After this line executes the session is cleared and the next page navigation redirects to the login screen.