OpenQA.Selenium.CookieImplementationTest.ShouldAddCookieToCurrentDomainAndPath C# (CSharp) Méthode

ShouldAddCookieToCurrentDomainAndPath() private méthode

private ShouldAddCookieToCurrentDomainAndPath ( ) : void
Résultat void
        public void ShouldAddCookieToCurrentDomainAndPath()
        {
            // Cookies cannot be set on domain names with less than 2 dots, so
            // localhost is out. If we are in that boat, bail the test.
            string hostName = EnvironmentManager.Instance.UrlBuilder.HostName;
            string[] hostNameParts = hostName.Split(new char[] { '.' });
            if (hostNameParts.Length < 3)
            {
                Assert.Ignore("Skipping test: Cookies can only be set on fully-qualified domain names.");
            }
            driver.Url = macbethPage;
            IOptions options = driver.Manage();
            Cookie cookie = new Cookie("Homer", "Simpson", hostName, "/" + EnvironmentManager.Instance.UrlBuilder.Path, null);
            options.AddCookie(cookie);
            ReadOnlyCollection<Cookie> cookies = options.GetCookies();
            Assert.That(cookies.Contains(cookie), "Valid cookie was not returned");
        }