views:

634

answers:

4

I'm running many tests (on FF) one after the other and I would like each test to start off with a fresh browser (ie no cookies, no cache,..). One idea is to close the browser and open a fresh one for the new test (this will create a new profile and probably the cleanest environment possible).

This is causing too much trouble and taking too long so I'll give away some of the security of having a new profile for not closing the browser. How would you do such a thing? And is clearing the cookies enough?

A: 

There is a keystroke that I hit once in awhile—accidentally—which asks what to clear, and offers cookies, cache, etc. (I don't know what it is at the moment.)

The Tools menu of v3.6 has Clear Recent History      Ctrl+Shift+Del. You could use that.

wallyk
sorry, I'm using selenium-RC.. I should have said that in the question
Guy
Why not have the test script begin by clearing the cache and cookies?
wallyk
no problem. How do you do that?
Guy
+1  A: 

I know that ctrl+shift and refresh clears the cache and cookies, therefore after each test method you can initiate a refresh while pressing ctrl+shift.

Alternative solution would be to write a java script that deletes all the cookies and cache and run getEval script to run the java script after each test method.

Selenium RC also have a function deleteCookies which deletes all the cookies, you can call this method after each test so that selenium deletes the cookies.

I hope this helps.

haroonzone
+1  A: 

Hi.

You did not mention the language driver you are using. Regardless, it should be something along the line of:

deleteCookie(cookieName, options)

Example:

deleteCookie('preferredColor', 'path=/')

For complete API reference see here

In my case using PHP:

$this->deleteCookie('uagent', 'path=/');

If you instead want to delete every cookie use deleteAllVisibleCookies().

Hope that helps.

SyaZ
A: 

did you get solutions of this ? I am interested to know.

What I am doing is Set "do not remember " option and close the browser every time I need fresh browser ....