/// <summary> /// Clears the browser cookies associated with a particular site and to /// any of the site's subdomains. /// </summary> /// <remarks> /// Internet Explorer maintains an internal cookie cache that does not immediately /// expire when cookies are cleared. This is the case even when the cookies are /// cleared using the Internet Options dialog. If cookies have been used by /// the current browser session it may be necessary to <see cref="Browser.Reopen()" /> the /// browser to ensure the internal cookie cache is flushed. Therefore it is /// recommended to clear cookies at the beginning of the test before navigating /// to any pages (other than "about:blank") to avoid having to reopen the browser. /// </remarks> /// <param name="url">The site url associated with the cookie.</param> /// <example> /// <code> /// // Clear cookies first. /// IE ie = new IE(); /// ie.ClearCookies("http://www.example.com/"); /// /// // Then go to the site and sign in. /// ie.GoTo("http://www.example.com/"); /// ie.Link(Find.ByText("Sign In")).Click(); /// </code> /// </example> /// <seealso cref="Browser.Reopen()"/> public void ClearCookies(string url) { if (url == null) { throw new ArgumentNullException("url"); } Logger.LogAction(String.Format("Clearing cookies for site '{0}'.", url)); WinInet.ClearCookies(url); }
/// <summary> /// Clears all browser cookies. /// </summary> /// <remarks> /// Internet Explorer maintains an internal cookie cache that does not immediately /// expire when cookies are cleared. This is the case even when the cookies are /// cleared using the Internet Options dialog. If cookies have been used by /// the current browser session it may be necessary to <see cref="Browser.Reopen()" /> the /// browser to ensure the internal cookie cache is flushed. Therefore it is /// recommended to clear cookies at the beginning of the test before navigating /// to any pages (other than "about:blank") to avoid having to reopen the browser. /// </remarks> /// <example> /// <code> /// // Clear cookies first. /// IE ie = new IE(); /// ie.ClearCookies(); /// /// // Then go to the site and sign in. /// ie.GoTo("http://www.example.com/"); /// ie.Link(Find.ByText("Sign In")).Click(); /// </code> /// </example> /// <seealso cref="Browser.Reopen()"/> public void ClearCookies() { Logger.LogAction("Clearing cookies for all sites."); WinInet.ClearCookies(null); }