OpenQA.Selenium.WindowSwitchingTest.CloseShouldCloseCurrentHandleOnly C# (CSharp) Méthode

CloseShouldCloseCurrentHandleOnly() private méthode

private CloseShouldCloseCurrentHandleOnly ( ) : void
Résultat void
        public void CloseShouldCloseCurrentHandleOnly()
        {
            driver.Url = xhtmlTestPage;
            driver.FindElement(By.LinkText("Open new window")).Click();

            string handle1, handle2;
            handle1 = driver.GetWindowHandle();

            driver.SwitchTo().Window("result");
            handle2 = driver.GetWindowHandle();

            driver.Close();

            SleepBecauseWindowsTakeTimeToOpen();

            ReadOnlyCollection<string> handles = driver.GetWindowHandles();

            Assert.IsFalse(handles.Contains(handle2), "Invalid handle still in handle list");
            Assert.IsTrue(handles.Contains(handle1), "Valid handle not in handle list");

            // Clean up after ourselves
            EnvironmentManager.Instance.CreateFreshDriver();
        }