mercredi 23 décembre 2015

unit test fails when changing the code, why?

my issue is that when I write this :

        _driver.FindElement(By.Id("signup_email")).SendKeys(email_1);
        IWebElement d = _driver.FindElement(By.Id("signup_password"));
        d.SendKeys(password_1);
        _driver.FindElement(By.CssSelector("#signup_forms_submit")).Click();

the test passes most of the time, but when I write this :

        _driver.FindElement(By.Id("signup_email")).SendKeys(email_1);
        IWebElement d = _driver.FindElement(By.Id("signup_password"));
        d.SendKeys(password_1);
        try
        {
            _driver.FindElement(By.CssSelector("#signup_forms_submit")).Click();
        }
        catch (Exception)
        {
            try
            {
                _driver.FindElement(By.CssSelector("#signup_forms_submit")).SendKeys(Keys.Enter);
            }
            catch (Exception)
            {
                try
                {
                    d.SendKeys(Keys.Enter);
                }
                catch (Exception)
                {
                    d.Submit();
                }
            }
        }
    }

the test fails most of the time, can anyone tell me why?

Aucun commentaire:

Enregistrer un commentaire