25

I'm writing Selenium tests for an ASP application, and would like to test the cases when a session isn't properly initialized. Right now I'm clearing the cookies manually, but that is becoming a bit cumbersome.

(ok, to be honest I forget it every fifth-or-so time and have to re-run the tests...)

Is there a way in Selenium IDE to clear session cookies or fake a browser re-start?

Anders Lindahl
  • 41,582
  • 9
  • 89
  • 93

5 Answers5

29

Found it myself, when I stopped thinking in terms of clear and tried delete:

Anders Lindahl
  • 41,582
  • 9
  • 89
  • 93
14

I've found it most useful to simply begin all tests with a call to my logout page, and on that page purposely expire any sessions the user may have.

Matthew Lock
  • 13,144
  • 12
  • 92
  • 130
2
deleteAllVisibleCookies

and put the site url in target

Mai Hanafy
  • 91
  • 7
2

use deletecookies or deleteAllVisibleCookies below is the example and you can get solution from here

<tr>
<td>open</td>
<td>www.google.co.in</td>
<td></td>
</tr>
 <tr>
<td>deleteAllVisibleCookies</td>
 <td>PREF</td>
 <td>domain=.google.co.in, recurse=true</td>
  </tr>
  <tr>
<td>deleteAllVisibleCookies</td>
<td>NID</td>
  <td>domain=.google.co.in, recurse=true</td>
 </tr>
Community
  • 1
  • 1
Ankit jain
  • 4,198
  • 4
  • 19
  • 24
1

I had the same problem in a PHP Project.

deleteAllVisibleCookies() removed too much for me. E.g. if a cookie for a rememberMe function was created by the application.

Instead I used $this->deleteCookie('PHPSESSID'); which delete the session.

Jesper Grann Laursen
  • 2,357
  • 1
  • 20
  • 21