/// <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> /// Sets the value of a cookie. /// </summary> /// <remarks> /// If no expiration date is specified, the cookie expires when the session ends. /// </remarks> /// <param name="url">The site url associated with the cookie.</param> /// <param name="cookieData">The cookie data of the form: /// <name>=<value>[; <name>=<value>]... /// [; expires=<date:DAY, DD-MMM-YYYY HH:MM:SS GMT>][; domain=<domain_name>] /// [; path=<some_path>][; secure][; httponly].</param> /// <seealso cref="ClearCookies()"/> /// <seealso cref="GetCookie(string,string)"/> public void SetCookie(string url, string cookieData) { WinInet.SetCookie(url, cookieData); }
public System.Net.CookieCollection GetCookiesForUrl(Uri url) { return(WinInet.GetCookiesForUrl(url)); }
public System.Net.CookieContainer GetCookieContainerForUrl(Uri url) { return(WinInet.GetCookieContainerForUrl(url)); }
/// <summary> /// Gets the value of a cookie. /// </summary> /// <remarks> /// This method cannot retrieve the value of cookies protected by the <c>httponly</c> security option. /// </remarks> /// <param name="url">The site url associated with the cookie.</param> /// <param name="cookieName">The cookie name.</param> /// <returns>The cookie data of the form: /// <name>=<value>[; <name>=<value>]... /// [; expires=<date:DAY, DD-MMM-YYYY HH:MM:SS GMT>][; domain=<domain_name>] /// [; path=<some_path>][; secure][; httponly]. Returns null if there are no associated cookies.</returns> /// <seealso cref="ClearCookies()"/> /// <seealso cref="SetCookie(string,string)"/> public string GetCookie(string url, string cookieName) { return(WinInet.GetCookie(url, cookieName)); }
/// <summary> /// Clears the browser cache but leaves cookies alone. /// </summary> /// <example> /// <code> /// // Clear the cache and cookies. /// IE ie = new IE(); /// ie.ClearCache(); /// 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 ClearCache() { Logger.LogAction("Clearing browser cache."); WinInet.ClearCache(); }
/// <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); }