Ejemplo n.º 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"))); });
        }
        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);
        }
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
        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;
            }));
        }
Ejemplo n.º 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);
        }
 public void ShouldNotFindPopupWindowWhenNoneExists()
 {
     driver.Url = xhtmlTestPage;
     PopupWindowFinder finder = new PopupWindowFinder(driver);
     string            handle = finder.Click(driver.FindElement(By.Id("linkId")));
 }
Ejemplo n.º 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"))); });
 }
Ejemplo n.º 11
0
 public void ShouldNotFindPopupWindowWhenNoneExists()
 {
     driver.Url = xhtmlTestPage;
     PopupWindowFinder finder = new PopupWindowFinder(driver);
     string handle = finder.Click(driver.FindElement(By.Id("linkId")));
 }
        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;
        }