Esempio n. 1
0
        /// <summary>
        /// Method used to switch focus to pop-up window and return main window handle so we can switch back to main window later.
        /// </summary>
        public void SwitchToPopUp(By elementThatCreatesPopup)
        {
            PopupWindowFinder finder    = new PopupWindowFinder(driver);
            string            newHandle = finder.Click(Driver.FindElement(elementThatCreatesPopup));

            Driver.SwitchTo().Window(newHandle);
        }
Esempio n. 2
0
        private string OpenAbtAnualReview(string year)
        {
            finder = new PopupWindowFinder(SeleniumDriver.Instance);
            string winHandle = finder.Click(SeleniumDriver.Instance.FindElement(By.LinkText("Abt Annual Review " + year)));

            return(winHandle);
        }
Esempio n. 3
0
        public void OpenOffice365LoginFormPopup()
        {
            Log.Info("Switching to new window");
            Store.MainHandle = Browser.GetDriver().CurrentWindowHandle;
            var finder = new PopupWindowFinder(Browser.GetDriver());

            addTenantButton.WaitForElementPresent();
            addTenantButton.WaitForElementIsClickable();
            try
            {
                var popupWindowHandle =
                    finder.Click(
                        Browser.GetDriver()
                        .FindElement(By.XPath("//div[@aria-expanded='true']//button[contains(@data-bind, 'addTenant')]")));
                Browser.GetDriver().SwitchTo().Window(popupWindowHandle);
            }
            catch (Exception)
            {
                Log.Info("Add tenant button is not ready");
                var popupWindowHandle =
                    finder.Click(
                        Browser.GetDriver()
                        .FindElement(By.XPath("//div[@aria-expanded='true']//button[contains(@data-bind, 'addTenant')]")));
                Browser.GetDriver().SwitchTo().Window(popupWindowHandle);
            }
        }
Esempio n. 4
0
        /// <summary>Function to swtich to pop-up page</summary>
        public void SwitchToPopup_Xpath(IWebDriver driver, string Xpath)
        {
            Thread.Sleep(PageConstants.Delay3);
            PopupWindowFinder finder = new PopupWindowFinder(driver);

            driver.SwitchTo().Window(finder.Click(driver.FindElement(By.XPath(Xpath))));
        }
Esempio n. 5
0
        public static bool OpenPdf(int rowIndex)
        {
            string pdfWindow     = "div.k-widget.k-window";
            string pdfTitle      = "div.k-window-titlebar.k-header";
            string pdfClose      = "a.k-window-action.k-link";
            string pdfDivId      = "analPopup"; //object id='pdf' data='https://uat.cmtanalytics.com/pdf/184.pdf';
            bool   opened        = false;
            string currentHandle = Driver.Instance.CurrentWindowHandle;
            var    finder        = new PopupWindowFinder(Driver.Instance);

            try
            {
                // Get the current window handle so you can switch back later.

                // Find the element that triggers the popup when clicked on.
                string      pdfClick = string.Format(format: "//*[@id='profileGrid']/div[2]/table/tbody/tr[{0}]/td[5]/div", arg0: rowIndex);
                IWebElement element  = Driver.Instance.FindElement(By.XPath(xpathToFind: pdfClick));
                element.Click();// Makes the popup window visible

                IWebElement window = Driver.Instance.FindElement(By.CssSelector(pdfWindow));
                IWebElement title  = window.FindElement(By.CssSelector(pdfTitle));
                IWebElement close  = title.FindElement(By.CssSelector(pdfClose));
                IWebElement pdf    = Driver.Instance.FindElement(By.Id(pdfDivId));

                close.Click();

                //string popupWindowHandle = finder.Click(element);
                //Driver.Instance.SwitchTo().Window(popupWindowHandle);
                //Driver.Instance.SwitchTo().Window(Driver.Instance.WindowHandles.ToList().Last());
                //string closeButton = "/html/body/div[4]/div[1]/div/a";
                //IWebElement closeBtn = Driver.Instance.FindElement(By.XPath(xpathToFind: closeButton));
                //closeBtn.Click();
                opened = true;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            finally
            {
                // The Click method of the PopupWindowFinder class will click
                // the desired element, wait for the popup to appear, and return
                // the window handle to the popped-up browser window. Note that
                // you still need to switch to the window to manipulate the page
                // displayed by the popup window.
                //var finder = new PopupWindowFinder(Driver.Instance);
                //string popupWindowHandle = finder.Click(element);

                //Driver.Instance.SwitchTo().Window(popupWindowHandle);
                //string closeButton = "/html/body/div[4]/div[1]/div/a";
                //IWebElement closeBtn = Driver.Instance.FindElement(By.XPath(xpathToFind: closeButton));
                //closeBtn.Click();

                //// Do whatever you need to on the popup browser, then...
                //Driver.Instance.Close();
                Driver.Instance.SwitchTo().Window(currentHandle);
                finder = null;
            }
            return(opened);
        }
        /// <summary>
        /// Performs the <paramref name="action"/> which causes new window to open.
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="action">Action to perform which causes new window to open.</param>
        /// <param name="oldWindowHandle">Window handle for the existing window (in order to be able to switch back to it).</param>
        /// <param name="newWindowHandle">Window handle for the new window (in order to be able to switch to it and do something).</param>
        public static void NewWindow(this IWebDriver driver, Action action, out string oldWindowHandle, out string newWindowHandle)
        {
            oldWindowHandle = driver.CurrentWindowHandle;
            var finder = new PopupWindowFinder(driver, new TimeSpan(0, 1, 0));

            newWindowHandle = finder.Invoke(action);
        }
Esempio n. 7
0
        private string OpenPPtReadingMode()
        {
            finder = new PopupWindowFinder(SeleniumDriver.Instance);
            string winHandle = finder.Click(_viewPresentation);

            return(winHandle);
        }
        public static void SwitchToChildWindow(By element)
        {
            PopupWindowFinder WindowHandler     = new PopupWindowFinder(driver);
            string            popupWindowHandle = WindowHandler.Click(driver.FindElement(element));

            driver.SwitchTo().Window(popupWindowHandle);
        }
Esempio n. 9
0
        public void DadoLoginEfetuado()
        {
            WebDriverWait wait = new WebDriverWait(webdriver, new TimeSpan(0, 0, 5));

            string currentHandle = webdriver.CurrentWindowHandle;
            ReadOnlyCollection <string> originalHandles = webdriver.WindowHandles;

            var buttonLogin = wait.Until <IWebElement>(ExpectedConditions.ElementIsVisible(By.ClassName("btn-login")));

            PopupWindowFinder finder            = new PopupWindowFinder(webdriver);
            string            popupWindowHandle = finder.Click(buttonLogin);


            webdriver.SwitchTo().Window(popupWindowHandle);

            var inputPassword = wait.Until <IWebElement>(ExpectedConditions.ElementIsVisible(By.Name("passwordHint")));

            inputPassword.Click();

            var password = webdriver.FindElement(By.Id("password"));

            password.SendKeys("nowmulti1");


            var inputUserName = wait.Until <IWebElement>(ExpectedConditions.ElementIsVisible(By.Name("username")));

            inputUserName.SendKeys("nowmultiscreen1");

            webdriver.FindElement(By.Name("_submit")).Click();

            webdriver.SwitchTo().Window(currentHandle);
        }
Esempio n. 10
0
        public void OpenCustomizeLink()
        {
            finder = new PopupWindowFinder(SeleniumDriver.Instance);
            string WinHandle = finder.Click(customizeLink);

            SeleniumDriver.Instance.SwitchTo().Window(WinHandle);
        }
Esempio n. 11
0
        /// <summary>
        /// Fetch the download link of the desired update by using the Selenium Firefox driver (a Firefox installation in the default directory is needed).
        /// </summary>
        /// <param name="searchUrl">Url of the starting website.</param>
        /// <param name="htmlID">Unique HTML ID of the specific update (e.g. 26896846-497d-4755-893a-6870f72ddcf4). This is only exposed in the HTML source code, however it is usable as a search parameter for the Microsoft Update Catalog</param>
        /// <returns>Direct download link to the specific update.</returns>
        private string FetchDownloadLinkFirefox(string searchUrl, string htmlID)
        {
            FirefoxDriverService driverService = FirefoxDriverService.CreateDefaultService();

            driverService.HideCommandPromptWindow = true;
            FirefoxOptions options = new FirefoxOptions();

            options.AddArguments("-headless");
            IWebDriver driver = new FirefoxDriver(driverService, options, TimeSpan.FromSeconds(10));

            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
            driver.Navigate().GoToUrl(searchUrl);
            IWebElement       test              = driver.FindElement(By.XPath($"//input[@id='{htmlID}' and @value='Download']"));
            PopupWindowFinder finder            = new PopupWindowFinder(driver);
            string            popupWindowHandle = finder.Click(test);

            driver.SwitchTo().Window(popupWindowHandle);
            ReadOnlyCollection <IWebElement> downloadLinkElements = driver.FindElements(By.PartialLinkText(""));

            foreach (IWebElement downloadLinkElement in downloadLinkElements)
            {
                string downloadLink = downloadLinkElement.GetAttribute("href");
                if (downloadLink.EndsWith(".msu"))
                {
                    driver.Quit();
                    return(downloadLink);
                }
            }

            return(null);
        }
Esempio n. 12
0
        public static void WaitForNewWindowAndSwitchToIt(this IWebDriver driver, IWebElement clickElement)
        {
            PopupWindowFinder waitForNewWindow = new PopupWindowFinder(driver);
            string            newWindowHandler = waitForNewWindow.Click(clickElement);

            driver.SwitchTo().Window(newWindowHandler);
        }
Esempio n. 13
0
        /// <summary>
        /// Switching to popup, and returns current windows handler
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="elementToClickOn"></param>
        /// <returns></returns>
        private static void Popup(IWebDriver driver, IWebElement elementToClickOn)
        {
            var finder            = new PopupWindowFinder(driver, TimeSpan.FromSeconds(20));
            var popupWindowHandle = finder.Click(elementToClickOn);

            driver.SwitchTo().Window(popupWindowHandle);
        }
Esempio n. 14
0
        public string OpenSuccessFactors()
        {
            finder = new PopupWindowFinder(SeleniumDriver.Instance);
            string WinHandle = finder.Click(Atlas);

            StartTimer();
            return(WinHandle);
        }
Esempio n. 15
0
        public StyleInside Style()
        {
            SwitchToMain();
            PopupWindowFinder wndFinder    = new PopupWindowFinder(driver);
            string            newWndHandle = wndFinder.Click(table);

            return(new StyleInside(_pagesFactory, newWndHandle));
        }
Esempio n. 16
0
        public StyleNEWPageObjects ClickNewStyle()
        {
            SwitchToMain();
            PopupWindowFinder wndFinder    = new PopupWindowFinder(driver);
            string            newWndHandle = wndFinder.Click(btnNew);

            return(new StyleNEWPageObjects(_pagesFactory, newWndHandle));
        }
Esempio n. 17
0
        public string OpenAbtXchange()
        {
            finder = new PopupWindowFinder(SeleniumDriver.Instance);
            string AbtXchangeHandle = finder.Click(AbtXchange);

            StartTimer();
            return(AbtXchangeHandle);
        }
Esempio n. 18
0
        public string OpenAbtTravel()
        {
            finder = new PopupWindowFinder(SeleniumDriver.Instance);
            string handle = finder.Click(AbtTravel);

            StartTimer();
            return(handle);
        }
Esempio n. 19
0
        public string GoToEbscoDS()
        {
            finder = new PopupWindowFinder(SeleniumDriver.Instance);
            string EbscoWinHandle = finder.Click(EbscoDS);

            StartTimer();
            return(EbscoWinHandle);
        }
Esempio n. 20
0
        public string GoToRightFind()
        {
            finder = new PopupWindowFinder(SeleniumDriver.Instance);
            string RightFindWinHandle = finder.Click(RightFindLink);

            StartTimer();
            return(RightFindWinHandle);
        }
Esempio n. 21
0
        public string OpenOracle()
        {
            finder = new PopupWindowFinder(SeleniumDriver.Instance);
            string WinHandle = finder.Click(oracleLink);

            StartTimer();

            return(WinHandle);
        }
        protected void HandlePopup(Action lookupTrigger, Action lookupAction)
        {
            PopupWindowFinder popupFinder         = new PopupWindowFinder(driver);
            String            popupHandle         = popupFinder.Invoke(lookupTrigger);
            String            currentWindowHandle = driver.CurrentWindowHandle;

            driver.SwitchTo().Window(popupHandle);
            lookupAction();
            driver.SwitchTo().Window(currentWindowHandle);
        }
Esempio n. 23
0
        public void OpenSearchWindow()
        {
            _mainWindowHandle = _webDriver.CurrentWindowHandle;
            Debug.WriteLine($"MainWindowHandle = {_mainWindowHandle}");
            var finder            = new PopupWindowFinder(_webDriver);
            var popupWindowHandle = finder.Click(SearchButton);

            Debug.WriteLine($"popupWindowHandle = {popupWindowHandle}");
            Debug.WriteLine($"MainWindow.pagesource = {_webDriver.PageSource}");
            _webDriver.SwitchTo().Window(popupWindowHandle);
            Debug.WriteLine($"PopUp.pagesource = {_webDriver.PageSource}");
        }
        public void Confirmation()
        {
            var currentHandle            = ObjectRepository.Driver.CurrentWindowHandle;
            PopupWindowFinder finder     = new PopupWindowFinder(ObjectRepository.Driver);
            WebDriverWait     customWait = new WebDriverWait(ObjectRepository.Driver, TimeSpan.FromMinutes(2));

            customWait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath(ExcelHelper.GetCellData(acr.GetXlpath(), "Details", 24, 1).ToString())));
            string popupWindowHandle = finder.Click(ObjectRepository.Driver.FindElement(By.XPath(ExcelHelper.GetCellData(acr.GetXlpath(), "Details", 24, 1).ToString())));

            ObjectRepository.Driver.SwitchTo().Window(popupWindowHandle);
            ObjectRepository.Driver.SwitchTo().Window(currentHandle);
            //ObjectRepository.Driver.FindElement(By.XPath(ExcelHelper.GetCellData(acr.GetXlpath(), "Details", 24, 1).ToString())).Click();
        }
 private void OpenWindowFor(IWebElement link)
 {
     finder = new PopupWindowFinder(SeleniumDriver.Instance);
     wait.IgnoreExceptionTypes(typeof(StaleElementReferenceException));
     wait.Until(e => link.Displayed);
     popupWindowHandle = finder.Click(link);
     //   var currentHandler = SeleniumDriver.Instance.CurrentWindowHandle;
     //   Console.WriteLine("This is the first popwindowHandle:");
     //  Console.WriteLine(currentHandler);
     wait.Until(d => SeleniumDriver.Instance.WindowHandles.Count >= 2);
     StartTimer();
     SeleniumDriver.Instance.SwitchTo().Window(popupWindowHandle);
     SeleniumDriver.Instance.Manage().Window.Maximize();
 }
Esempio n. 26
0
        public string CreateNewWillTypeFacebook(IWebDriver driver)
        {
            new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Id("offer")));
            driver.FindElement(By.Id("offer")).Click();
            driver.FindElement(By.ClassName("create-will")).Click();
            driver.FindElements(By.ClassName("signup"))[0].Click();
            driver.FindElements(By.ClassName("signup"))[0].Click();
            IWebElement element = driver.FindElement(By.ClassName("fb-login-button"));

            PopupWindowFinder Finder            = new PopupWindowFinder(driver);
            string            popupWindowHandle = Finder.Click(element);

            driver.SwitchTo().Window(popupWindowHandle);

            return(driver.Url);
        }
        public void BookOrSearchUsTravel()
        {
            // action.MoveToElement()
            finder = new PopupWindowFinder(SeleniumDriver.Instance);
            Console.WriteLine("Clicking on Book or Search US Travel");
            Console.WriteLine("</br>");

            popupWindowHandle = finder.Click(concurLink);
            StartTimer();
            SeleniumDriver.Close();
            SeleniumDriver.Instance.SwitchTo().Window(popupWindowHandle);
            SeleniumDriver.Instance.Manage().Window.Maximize();
            wait.Until(e => warning.Displayed);
            warning.Click();
            StopTimer();
            PrintResponseTime("Concur");
        }
Esempio n. 28
0
        private void clicker(FirefoxDriver driver, string id, string id_rouge, string bouton_final_absent, int speed)
        {
            //On va reperer le lien qui nous mene vers une nouvelle feetre
            string currentHandle = driver.CurrentWindowHandle;

            if (id_rouge != "0")                    //Si l'on s'occupe d'une pub normal
            {
                driver.FindElementById(id).Click(); //On clique sur l'annonce
                wait(1, 3);
                IWebElement       element           = driver.FindElementByXPath(id_rouge);
                PopupWindowFinder finder            = new PopupWindowFinder(driver);
                string            popupWindowHandle = finder.Click(element);
                driver.SwitchTo().Window(popupWindowHandle);
            }
            else //Si c'est une adprize
            {
                IWebElement       element           = driver.FindElementById(id);
                PopupWindowFinder finder            = new PopupWindowFinder(driver);
                string            popupWindowHandle = finder.Click(element);
                driver.SwitchTo().Window(popupWindowHandle);
            }

            //On fait une boucle pour ne pas attendre plus de 3 mins (si la pub a crash)
            DateTime startingTime = DateTime.Now;

            wait(1, 3);
            bool pubVue = false;

            while (!three_minuts(startingTime) && !pubVue)
            {
                if (!estPresent(driver, By.XPath(bouton_final_absent)))
                {
                    driver.FindElementByCssSelector("a.button.small2.orange").Click();
                    pubVue = true;
                }
                else
                {
                    wait(1, 3);
                }
            }

            //On reveient a la fenetre d'origine
            driver.SwitchTo().Window(currentHandle);
        }
Esempio n. 29
0
        public void Desktop_e2e_login_test()
        {
            var appiumOptions = new OpenQA.Selenium.Appium.AppiumOptions();

            appiumOptions.AddAdditionalCapability("app", @"C:\Users\9i9i\source\repos\MailSystemDesktopApp\MailSystemDesktopApp\bin\Debug\net5.0-windows\MailSystemDesktopApp.exe");
            var applicationSession = new WindowsDriver <WindowsElement>(new Uri("http://127.0.0.1:4723"), appiumOptions);

            applicationSession.FindElementByName("loginTextBox").SendKeys("admin");
            applicationSession.FindElementByName("passwordTextBox").SendKeys("admin");
            //applicationSession.FindElementByClassName("Button").Click();
            string            current   = applicationSession.CurrentWindowHandle;
            PopupWindowFinder finder    = new PopupWindowFinder(applicationSession);
            string            newHandle = finder.Click(applicationSession.FindElementByClassName("Button"));

            applicationSession.SwitchTo().Window(newHandle);
            applicationSession.FindElementByName("titleTextBox").SendKeys("test");
            var testText = applicationSession.FindElementByName("titleTextBox").Text;

            Assert.IsNotNull(testText);
        }
Esempio n. 30
0
 public Boolean LoopThorughAllFLowsAndRun()
 {
     this.Execute("JobOrders", driver =>
     {
         Thread.Sleep(3000);
         int count = driver.FindElements(By.XPath("//div[normalize-space(text())='Off']/../..//a")).Count();
         for (int i = 0; i < count; i++)
         {
             var ele        = driver.FindAvailable(By.XPath($"(//div[normalize-space(text())='Off']/../..//a)[{i + 1}]"));
             var popup      = new PopupWindowFinder(driver);
             string session = popup.Click(ele);
             driver.SwitchTo().Window(session);
             string result = TurnOn() == true ? "is turned On" : "is not turned On";
             Console.WriteLine(ele.Text + " => " + result);
             driver.Close();
         }
         return(true);
     });
     return(true);
 }