views:

1062

answers:

3

Is it possible to disable a browser cookie using selenium, RC specifically? If so, what is the api call or sequence of calls to make this happen. There is a feature being tested where theres a need to verify the behavior when cookies are enabled or disabled. Thanks

+1  A: 

As specified in the comment. If you are using FF, you could specify the profile to be used.

The way to do it it so specify the browserStartCommand (3rd argument of the DefaultSelenium constructor) to something similar to:

*custom "C:/Program Files/Mozilla Firefox/firefox.exe" -no-remote -profile "C:/Some/Path/To/Mozilla/Firefox/Profiles/selenium"

And this profile you could have the cookies disabled.

Grzegorz Oledzki
A: 

Another idea (I haven't tried that) would be to use a special proxy between the Selenium RC client and the tested web application. The proxy would be able to filter the cookies when asked to.

There are some proxy implementations intended for development, debugging and tracing roles. I am pretty sure you can find one with the feature to block cookies.

EDIT: This solution has the advantage of being browser-independent.

Grzegorz Oledzki
A: 

If you are going to be using Firefox there is a specific command to access the firefox template. You use

-firefoxProfileTemplate "path to the profile"

as described here. I would use the different profiles for cookies on and off as that way you can control it a lot better.

AutomatedTester