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

AddCookiesWithDifferentPathsThatAreRelatedToOurs() private méthode

private AddCookiesWithDifferentPathsThatAreRelatedToOurs ( ) : void
Résultat void
        public void AddCookiesWithDifferentPathsThatAreRelatedToOurs()
        {
            driver.Url = simpleTestPage;
            driver.Manage().DeleteAllCookies();
            string basePath = EnvironmentManager.Instance.UrlBuilder.Path;

            Cookie cookie1 = new Cookie("fish", "cod", "/" + basePath + "/animals");
            Cookie cookie2 = new Cookie("planet", "earth", "/" + basePath + "/");
            IOptions options = driver.Manage();
            options.AddCookie(cookie1);
            options.AddCookie(cookie2);

            UrlBuilder builder = EnvironmentManager.Instance.UrlBuilder;
            driver.Url = builder.WhereIs("animals");

            ReadOnlyCollection<Cookie> cookies = options.GetCookies();
            Assert.IsTrue(cookies.Contains(cookie1));
            Assert.IsTrue(cookies.Contains(cookie2));

            driver.Url = builder.WhereIs("");
            cookies = options.GetCookies();
            Assert.IsFalse(cookies.Contains(cookie1));
            Assert.IsTrue(cookies.Contains(cookie2));
        }