예제 #1
0
        /// <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);
        }
예제 #2
0
 /// <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:
 /// &lt;name&gt;=&lt;value&gt;[; &lt;name&gt;=&lt;value&gt;]...
 /// [; expires=&lt;date:DAY, DD-MMM-YYYY HH:MM:SS GMT&gt;][; domain=&lt;domain_name&gt;]
 /// [; path=&lt;some_path&gt;][; secure][; httponly].</param>
 /// <seealso cref="ClearCookies()"/>
 /// <seealso cref="GetCookie(string,string)"/>
 public void SetCookie(string url, string cookieData)
 {
     WinInet.SetCookie(url, cookieData);
 }
예제 #3
0
 public System.Net.CookieCollection GetCookiesForUrl(Uri url)
 {
     return(WinInet.GetCookiesForUrl(url));
 }
예제 #4
0
 public System.Net.CookieContainer GetCookieContainerForUrl(Uri url)
 {
     return(WinInet.GetCookieContainerForUrl(url));
 }
예제 #5
0
 /// <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:
 /// &lt;name&gt;=&lt;value&gt;[; &lt;name&gt;=&lt;value&gt;]...
 /// [; expires=&lt;date:DAY, DD-MMM-YYYY HH:MM:SS GMT&gt;][; domain=&lt;domain_name&gt;]
 /// [; path=&lt;some_path&gt;][; 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));
 }
예제 #6
0
        /// <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();
        }
예제 #7
0
        /// <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);
        }