Example #1
0
        public void ValidaOptin(int status)
        {
            _CNH = gerador.NumeroRandomico(11);

            var abaDocumentosLocaliza = new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementToBeClickable(abaDocumentos));

            abaDocumentosLocaliza.Click();

            driver.FindElement(txtCPF).SendKeys(CpfGerado + Keys.Tab);
            cpfComPontuacao = driver.FindElement(txtCPF).GetAttribute("value");

            if (status == 0)
            {
                var txtNrDocLocaliza = new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementToBeClickable(txtNrDoc));
                txtNrDocLocaliza.Clear();
                txtNrDocLocaliza.SendKeys(_CNH);

                driver.FindElement(txtNrReg).SendKeys(_CNH);
                driver.FindElement(btnSalvar).Click();
            }
            else if (status == 1 || status == 2)
            {
                Thread.Sleep(5000);

                driver.SwitchTo().ParentFrame();
                driver.SwitchTo().Frame(FRAME1);

                var txtNomeLocaliza = new WebDriverWait(driver, TimeSpan.FromSeconds(10)).Until(ExpectedConditions.ElementIsVisible(txtNome));
                Assert.Contains("TESTE AUTOMACAO OPTIN", txtNomeLocaliza.GetAttribute("value"));
                Assert.Equal("(47) 99911-8329", driver.FindElement(txtTelefone).GetAttribute("value"));
                Assert.Equal(cpfComPontuacao, driver.FindElement(txtCPF).GetAttribute("value"));
            }
        }
Example #2
0
        public void SendKeys(string elementDescriptor, By by, string textToSend)
        {
            try
            {
                IWebElement myElement = new WebDriverWait(this.driver, TimeSpan.FromSeconds(10)).Until(driver =>
                {
                    IWebElement tempElement = this.driver.FindElement(by);
                    return((tempElement.Displayed && tempElement.Enabled) ? tempElement : null);
                });

                myElement.Clear();
                myElement.SendKeys(textToSend);
                this.driver.Report().Step(
                    description: $"Sent '{textToSend}' to element '{elementDescriptor}' located by {by}",
                    passed: true);
            }
            catch (WebDriverException)
            {
                string errorMessage = $"Error in SendKeys(): could not locate element '{elementDescriptor}' located by {by}";

                this.driver.Report().Step(
                    description: errorMessage,
                    passed: false,
                    screenshot: true);

                Assert.Fail(errorMessage);
            }
        }
        public static void SendedToField(IWebDriver driver, By to, string inputText)
        {
            var inputElement = new WebDriverWait(driver, TimeSpan.FromSeconds(4)).
                               Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(to));

            new WebDriverWait(driver, TimeSpan.FromSeconds(5))
            .Until <IWebElement>((d) =>
            {
                inputElement.Clear();
                inputElement.SendKeys(inputText);

                if (inputElement.GetAttribute("value").Equals(inputText, StringComparison.Ordinal))
                {
                    return(inputElement);
                }

                return(null);
            });
        }