Before starting a fresh test (For Web based application), it’s always important that we start off with browser cache
and cookies cleared
. Well, it’s important because your application might have used cookies or browser might have cached your application pages, if your Developer or QA team had deployed a new build and you are trying to access your application with browser without clearing the cache or cookies, browser seldom render the pages which is cached.
I have incurred this problem many time while testing my web-based application, hence its super important to do cache and cookies cleaning before you start your Automation testing too.
Well, how can we do this using Coded UI Test?
The answer is simple, Coded UI Test has a dedicated class for browser, the name of class is BrowserWindow
, and there are many useful methods available in BrowserWindow which are useful while working with browser related stuffs as shown.
Here is the code for clearing cache and cookies in browser using BrowserWindow
BrowserWindow class is located in the following namespace Microsoft.VisualStudio.TestTools.UITesting
That’s it !!!
One Reply to “How to clear Cookies and cache of browser in Coded UI Test”
Thanks for the post. When I use BrowserWindow.ClearCache I get the following message, ClearCache is not supported on chrome.