コード例 #1
0
        public void ShouldNotFindPopupWindowWhenNoneExists()
        {
            driver.Url = xhtmlTestPage;
            PopupWindowFinder finder = new PopupWindowFinder(driver);

            Assert.Throws <WebDriverTimeoutException>(() => { string handle = finder.Click(driver.FindElement(By.Id("linkId"))); });
        }
コード例 #2
0
        public void ShouldFindMultiplePopupWindowsInSuccession()
        {
            driver.Url = xhtmlTestPage;
            string first = driver.CurrentWindowHandle;

            PopupWindowFinder finder = new PopupWindowFinder(driver);
            string            second = finder.Click(driver.FindElement(By.Name("windowOne")));

            Assert.IsNotNullOrEmpty(second);
            Assert.AreNotEqual(first, second);

            finder = new PopupWindowFinder(driver);
            string third = finder.Click(driver.FindElement(By.Name("windowTwo")));

            Assert.IsNotNullOrEmpty(third);
            Assert.AreNotEqual(first, third);
            Assert.AreNotEqual(second, third);

            driver.SwitchTo().Window(second);
            driver.Close();

            driver.SwitchTo().Window(third);
            driver.Close();

            driver.SwitchTo().Window(first);
        }
コード例 #3
0
        public void ShouldFindPopupWindowUsingElementClick()
        {
            driver.Url = xhtmlTestPage;
            string current = driver.CurrentWindowHandle;

            PopupWindowFinder finder    = new PopupWindowFinder(driver);
            string            newHandle = finder.Click(driver.FindElement(By.LinkText("Open new window")));

            Assert.IsNotNullOrEmpty(newHandle);
            Assert.AreNotEqual(current, newHandle);

            driver.SwitchTo().Window(newHandle);
            Assert.AreEqual("We Arrive Here", driver.Title);
            driver.Close();

            driver.SwitchTo().Window(current);
        }
コード例 #4
0
        public void ShouldFindPopupWindowUsingElementClick()
        {
            driver.Url = xhtmlTestPage;
            string current = driver.CurrentWindowHandle;

            PopupWindowFinder finder = new PopupWindowFinder(driver);
            string newHandle = finder.Click(driver.FindElement(By.LinkText("Open new window")));

            Assert.That(newHandle, Is.Not.Null.Or.Empty);
            Assert.AreNotEqual(current, newHandle);

            driver.SwitchTo().Window(newHandle);
            Assert.AreEqual("We Arrive Here", driver.Title);
            driver.Close();

            driver.SwitchTo().Window(current);
        }
コード例 #5
0
        public void ShouldFindPopupWindowUsingAction()
        {
            driver.Url = xhtmlTestPage;
            string current = driver.CurrentWindowHandle;

            PopupWindowFinder finder    = new PopupWindowFinder(driver);
            string            newHandle = finder.Invoke(() => { driver.FindElement(By.LinkText("Open new window")).Click(); });

            Assert.That(newHandle, Is.Not.Null.Or.Empty);
            Assert.AreNotEqual(current, newHandle);

            driver.SwitchTo().Window(newHandle);
            Assert.AreEqual("We Arrive Here", driver.Title);
            driver.Close();

            driver.SwitchTo().Window(current);
        }
コード例 #6
0
        public void ShouldFindPopupWindowUsingAction()
        {
            driver.Url = xhtmlTestPage;
            string current = driver.CurrentWindowHandle;

            PopupWindowFinder finder = new PopupWindowFinder(driver);
            string newHandle = finder.Invoke(() => { driver.FindElement(By.LinkText("Open new window")).Click(); });

            Assert.IsNotNullOrEmpty(newHandle);
            Assert.AreNotEqual(current, newHandle);

            driver.SwitchTo().Window(newHandle);
            Assert.AreEqual("We Arrive Here", driver.Title);
            driver.Close();

            driver.SwitchTo().Window(current);
        }
コード例 #7
0
        public string Invoke(Action popupMethod)
        {
            if (popupMethod == null)
            {
                throw new ArgumentNullException("popupMethod", "popupMethod cannot be null");
            }
            IList <string> existingHandles = this.driver.WindowHandles;

            popupMethod();
            WebDriverWait webDriverWait = new WebDriverWait(new SystemClock(), this.driver, this.timeout, this.sleepInterval);

            return(webDriverWait.Until <string>(delegate(IWebDriver d)
            {
                string result = null;
                IList <string> difference = PopupWindowFinder.GetDifference(existingHandles, this.driver.WindowHandles);
                if (difference.Count > 0)
                {
                    result = difference[0];
                }
                return result;
            }));
        }
コード例 #8
0
        public void ShouldFindMultiplePopupWindowsInSuccession()
        {
            driver.Url = xhtmlTestPage;
            string first = driver.CurrentWindowHandle;

            PopupWindowFinder finder = new PopupWindowFinder(driver);
            string second = finder.Click(driver.FindElement(By.Name("windowOne")));
            Assert.That(second, Is.Not.Null.Or.Empty);
            Assert.AreNotEqual(first, second);

            finder = new PopupWindowFinder(driver);
            string third = finder.Click(driver.FindElement(By.Name("windowTwo")));
            Assert.That(third, Is.Not.Null.Or.Empty);
            Assert.AreNotEqual(first, third);
            Assert.AreNotEqual(second, third);

            driver.SwitchTo().Window(second);
            driver.Close();

            driver.SwitchTo().Window(third);
            driver.Close();

            driver.SwitchTo().Window(first);
        }
コード例 #9
0
 public void ShouldNotFindPopupWindowWhenNoneExists()
 {
     driver.Url = xhtmlTestPage;
     PopupWindowFinder finder = new PopupWindowFinder(driver);
     string            handle = finder.Click(driver.FindElement(By.Id("linkId")));
 }
コード例 #10
0
 public void ShouldNotFindPopupWindowWhenNoneExists()
 {
     driver.Url = xhtmlTestPage;
     PopupWindowFinder finder = new PopupWindowFinder(driver);
     Assert.Throws<WebDriverTimeoutException>(() => { string handle = finder.Click(driver.FindElement(By.Id("linkId"))); });
 }
コード例 #11
0
 public void ShouldNotFindPopupWindowWhenNoneExists()
 {
     driver.Url = xhtmlTestPage;
     PopupWindowFinder finder = new PopupWindowFinder(driver);
     string handle = finder.Click(driver.FindElement(By.Id("linkId")));
 }
コード例 #12
0
        private RunLog Popup(string element)
        {
            RunLog thislog = new RunLog();
            try
            {
                
                IWebElement thisElement = WaitForElementToAppear(driver, 10, By.XPath(element));

                PopupWindowFinder finder = new PopupWindowFinder(driver);
                string popupWindowHandle = finder.Click(thisElement);

                driver.SwitchTo().Window(popupWindowHandle);

                thislog.Pass = true;
                thislog.Message = "Popup";
            }
            catch(Exception ex)
            {
                thislog.Pass = false;
                thislog.Message = ex.Message;
            }

            return thislog;
        }