Selenium-RC: what's the best way to clean your browser without rebooting

I run many tests (in FF) one by one, and I would like each test to start with a fresh browser (i.e. no cookies, no cache, ...). One idea is to close the browser and open a new one for a new test (this will create a new profile and possibly the cleanest environment).

This causes too many problems and takes too much time, so I will give away part of the security of the new profile so as not to close the browser. How would you do that? And clears cookies?

+4
source share
4 answers

I know that ctrl + shift and refresh clear the cache and cookies, so after each test method, you can initiate the update by pressing ctrl + shift.

An alternative solution would be to write a java script that removes all cookies and cache and runs a getEval script to run a java script after each test method.

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

Hope this helps.

+2
source

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

deleteCookie(cookieName, options) 

Example:

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

For a complete API reference, see here .

In my case using PHP:

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

If you want to delete each cookie, use deleteAllVisibleCookies ().

Hope this helps.

+1
source

If you use java, you can just use this in setUp ().

selenium.deleteAllVisibleCookies ();

Hope this works Fine

0
source

Did you get a solution? I am interested to know.

What I do is set the “don't remember” option and close the browser every time I need a new browser ...

-1
source

Source: https://habr.com/ru/post/1301207/


All Articles