Clearing cookies and browser data inside a test script

Asked by pratik shah on 2012-08-22

Is there a way I can clear my browser cookies in the middle of a test?

Example:

urls = array of urls

for url in urls:
    goto(url)
    // clear cookies/browser data

Any help would be appreciated! =)

Question information

Language:
English Edit question
Status:
Solved
For:
selenium-simple-test Edit question
Assignee:
No assignee Edit question
Solved by:
pratik shah
Solved:
2012-08-23
Last query:
2012-08-23
Last reply:
pratik shah (pratik-shah) said : #1

Answered my own question tonight, sorry I forgot the webdriver class is a toolbox, I just have to find the tool!

def delete_all_cookies():
    browser.delete_all_cookies()

define function above in actions.

Corey Goldberg (coreygoldberg) said : #2

pratik,
this sounds like a good addition to sst's actions.py.

Corey Goldberg (coreygoldberg) said : #3

pratik,
I just did a merge proposal, implementing this:
https://code.launchpad.net/~coreygoldberg/selenium-simple-test/clear-cookies

once it lands in trunk, a `clear_cookies()` action will be available in sst.actions.

-Corey

pratik shah (pratik-shah) said : #4

Sweet. It's especially useful for traffic slicer testing so you can iterate through pages and test the slicing between A and B.