Exemplo n.º 1
0
        protected void TimeWebPageAction()
        {
            By by = By.XPath("//h4[contains(text(),'Carregando')]");

            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1);

            while (IsElementPresentAndDisplayed(by))
            {
            #if DEBUG
                log.TraceInicioFim();
                log.TraceWriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name, Sigef.Poc.Ftcapp.Util.CONST.ConstTraceException.METODO);
                log.TraceIdentAndUniIdent(by.ToString(), Sigef.Poc.Ftcapp.Util.CONST.ConstTraceField.ELEMENTO);
                log.TraceInicioFim();
            #endif
            }

            while (!(JSUtil.PageLoad(driver)))
            {
                #if DEBUG
                log.TraceInicioFim();
                log.TraceWriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name, Sigef.Poc.Ftcapp.Util.CONST.ConstTraceException.METODO);
                log.TraceIdentAndUniIdent("PAGE LOADING", Sigef.Poc.Ftcapp.Util.CONST.ConstTraceField.PAGINA);
                log.TraceInicioFim();
                #endif
            }
        }
Exemplo n.º 2
0
        private bool RunActionWebDriverComand(string comando, string valor)
        {
            switch (comando)
            {
            case ConstActionCommand.ACTION_SWITCH_TO_FRAME:
                if (driver.PageSource.Contains("<iframe"))
                {
                    var         by     = By.XPath(valor);
                    IWebElement iframe = FindElementBy(by);;
                    var         tt     = driver.FindElements(By.XPath("//iframe[1]"));
                    driver.SwitchTo().Frame(iframe);
                }
                break;

            case ConstActionCommand.ACTION_GO_TO:
                do
                {
                    driver.Navigate().GoToUrl(valor);
                }while(!driver.Url.Contains(valor));
                break;

            case ConstActionCommand.ACTION_SWITCH_TO_BACK:
                try
                {
                    driver.Navigate().Back();
                }
                catch {
                }
                break;

            case ConstActionCommand.ACTION_SWITCH_TO_CONTAIS:
                do
                {
                    NavigateUtil.SwitchTocontains(driver, valor);
                }while (!driver.Url.Contains(valor));

                break;

            case ConstActionCommand.ACTION_SWITCH_TO_LAST:
                driver.SwitchTo().Window(driver.WindowHandles.Last());

                break;

            case ConstActionCommand.ACTION_RUN_JS:
                JSUtil.JavaScriptRun(driver, valor);
                break;

            case ConstActionCommand.ACTION_CLOSE_ALERT:
                if (NavigateUtil.IsAlertPresents(driver))
                {
                    try
                    {
                        driver.SwitchTo().Alert().Accept();
                    }
                    catch
                    {
                        return(true);
                    }
                }


                break;

            case ConstActionCommand.ACTION_ClOSE_ALL_PAGES:

                break;

            case ConstActionCommand.ACTION_SWITCH_TO:

                do
                {
                    driver.SwitchTo().Window(valor);
                }while (!driver.Url.Contains(valor));

                break;

            case ConstActionCommand.ACTION_GRID_GETFIRST_ITEM:
                driver.SwitchTo().Window(valor);
                break;
            }
            //TimeWebPageAction();
            return(true);
        }
Exemplo n.º 3
0
        private bool RunActionComand(string comando, IWebElement el, string valor)
        {
            try
            {
                switch (comando)
                {
                case ConstActionCommand.ACTION_CHECK:
                    el.Click();
                    break;

                case ConstActionCommand.ACTION_CLICK_ONCLIK:
                    var script = el.GetAttribute("onclick");
                    JSUtil.JavaScriptRun(driver, script);
                    break;

                case ConstActionCommand.ACTION_CLICK:

                    //WebElementUtil.GetWebElementByID(driver, el.GetAttribute("id")).Click();
                    //string url = driver.Url;

                    //el.Click();
                    try
                    {
                        el.Click();
                    }

                    catch (NoSuchWindowException ex)
                    {
                        driver.SwitchTo().Window(driver.WindowHandles.Last());
                    }
                    catch (Exception ex)
                    {
                        log.FormaTLogException(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.GetType().Name, ex.Message);
                    }
                    //var el3 = el.FindElements(By.TagName("//span[text()='Ajuda']"));
                    //var el2 = driver.FindElements(By.XPath("//span[text()]/preceding::button[not(contains(@style,'display:none')) and not(contains(@style,'display:hidden')) and contains(@class,'btn-primary')]"));
                    //driver.FindElement(By.Cod(el.GetAttribute("id"))).Click();
                    //el.Click();
                    break;

                case ConstActionCommand.ACTION_INSERT:
                    el.SendKeys(valor);
                    break;

                case ConstActionCommand.ACTION_INSERT_IF_EMPTY:
                    if ((el.Text == null && el.GetAttribute("value") == null) || (el.Text == "" && el.GetAttribute("value") == ""))
                    {
                        el.SendKeys(valor);
                    }

                    break;

                case ConstActionCommand.ACTION_SELECT:
                    var combobox = new SelectElement(el);
                    combobox.SelectByText(valor);
                    break;

                case ConstActionCommand.ACTION_GRID_GETFIRST_ITEM:
                    driver.SwitchTo().Window(valor);
                    break;

                    /*
                     * //tr[contains(@class,'GridLinha')][1]/following::td[1]
                     */
                }
            }
            catch (Exception ex) {
                Console.Write(ex.Message);
            }
            return(true);
        }