开发者

How to start new IE session with Watin

I need to know how to start a browser instance but with a new session. I tried to clear cookies and clear cache but this doe开发者_StackOverflow社区sn't give me what I need.

In my case I add products to a basket, then close the browser, then use another url that adds different product, but always the old products are still in the basket.


for IE6-7 you should start a new browser session in a new process like this:

var ie = new IE("yoururl", true);

for IE8-9 you should set the no-merge option on the settings class before creating a new IE instance:

Settings.MakeNewIe8InstanceNoMerge = true;
var ie = new IE("yoururl");


Make sure that you're closing the browser properly (i.e. closing all its tabs and windows, including downloads and such) - look at the task manager to see if it's still running. Session might not be cookie-based (for example, it could be tracked in the same process that processes the request), and clearing browser cache isn't going to affect the open sessions in any way.

Assuming that you're developing an asp.net application or website you may try to right-click on the ASP.NET Development Server icon in the system tray and stop it, then re-run your project. That should kill all sessions.


We had the same problem here. IE re-uses the session over all its browser instances. If you want a new session just do:

Alt (menu) -> File -> New Session

Check this blog for more info.


Sessions are managed by cookies, you can clear all your cookies or just for the site concerned.

Try searching for IE Clearing cookies


IE 9 has one more way of not clearing all the cookies. If you open the Dialog to Clear Cookies from the Options Menu in IE 9, you will notice that the first options says "Preserve Favorites Website Data." Leave this unchecked and you usual clear cookies, close browser should work.

Let me know if this helps, I think this should do the trick ;)


I will be trying this in WatiN soon, but just testing with my commandline switches, it looks like I can open multiple instances using

iexplore.exe -private -nomerge

and each instance will not interfere with the other ones.

This means it allows you to login with differnet logins on the same website, and they won't interfere with each other.

This needs further verificaiton, but so far it seems to work.

update: I found this old patch for WatiN that adds the privacy feature to the watin lib, it doesn't appear to currently be in the release- http://sourceforge.net/tracker/?func=detail&aid=3013950&group_id=167632&atid=843730

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜