public void EnviarCorreoError(NoSuchElementException no, string nombreMetodo)
        {
            try
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("mail.ingesmart.cl");

                mail.From = new MailAddress("*****@*****.**", "Alex Moreno Gamboa");
                //mail.To.Add("*****@*****.**");
                mail.To.Add("*****@*****.**");
                mail.CC.Add("*****@*****.**");
                mail.CC.Add("*****@*****.**");
                mail.CC.Add("*****@*****.**");
                mail.CC.Add("*****@*****.**");
                mail.CC.Add("*****@*****.**");
                mail.Subject = "Prueba " + nombreMetodo + "_ERROR";
                mail.Body    = "Estimados,\n         " +
                               "\n Se detecto un error al probar la prueba " + nombreMetodo + " se realizara la revisión de modificaciones en los elementos, se agrega el mensaje de error: " + "\n" + no.ToString();

                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Aemg.7375");
                SmtpServer.EnableSsl   = true;

                SmtpServer.Send(mail);
                Console.WriteLine("Enviado Error" + no);
            }
            catch (Exception exc)
            {
                Console.WriteLine("Error Encontrado" + exc.ToString());
            }
        }
        protected static void HandleNoElementException(NoSuchElementException nsee, string deviceModel, bool shouldThrow = true)
        {
            var message = deviceModel + "  in Test: " + TestContext.CurrentContext.Test.Name + " had Element not found: " + nsee.Message;

            if (shouldThrow)
            {
                Console.WriteLine(message + " stacktrace: " + nsee.StackTrace);
                ExecutionErrors.Add(new ExecutionError(message, GetTestMethodName(), nsee));
                throw new NoSuchElementException(message, nsee);
            }
        }
        protected static void HandleNoElementException(NoSuchElementException nsee, RemoteWebDriverExtended driver, bool shouldThrow = true)
        {
            var model   = GetDeviceModel(driver);
            var message = model + "  in Test: " + GetTestMethodName() + " had Element not found: " + nsee.Message;

            Console.WriteLine(message + " stacktrace: " + nsee.StackTrace);
            if (shouldThrow)
            {
                ExecutionErrors.Add(new ExecutionError(message, GetTestMethodName(), nsee));
                throw new NoSuchElementException(message, nsee);
            }
        }
 protected override bool EvaluateLoadedStatus()
 {
     try
     {
         element = elementFindingFunc();
         if (!elementIsUsableFunc(element))
         {
             throw new NoSuchElementException("Element is not usable");
         }
         return(true);
     }
     catch (NoSuchElementException e)
     {
         lastException = e;
         // Should use JUnit's AssertionError, but it may not be present
         throw new NoSuchElementException("Unable to locate the element", e);
     }
 }
        public void ShouldCallListenerOnException()
        {
            NoSuchElementException exception = new NoSuchElementException("argh");
            Expect.Once.On(mockDriver).Method("FindElement").With(By.Id("foo")).Will(Throw.Exception(exception));

            EventFiringWebDriver firingDriver = new EventFiringWebDriver(mockDriver);
            firingDriver.ExceptionThrown += new EventHandler<WebDriverExceptionEventArgs>(firingDriver_ExceptionThrown);

            try
            {
                firingDriver.FindElement(By.Id("foo"));
                Assert.Fail("Expected exception to be propogated");
            }
            catch (NoSuchElementException)
            {
                // Fine
            }

            Assert.AreEqual(exception.Message, log.ToString());
        }
Beispiel #6
0
        public void ShouldCallListenerOnException()
        {
            NoSuchElementException exception = new NoSuchElementException("argh");

            mockDriver.Expects.One.Method(_ => _.FindElement(null)).With(By.Id("foo")).Will(Throw.Exception(exception));

            EventFiringWebDriver firingDriver = new EventFiringWebDriver(mockDriver.MockObject);

            firingDriver.ExceptionThrown += new EventHandler <WebDriverExceptionEventArgs>(firingDriver_ExceptionThrown);

            try
            {
                firingDriver.FindElement(By.Id("foo"));
                Assert.Fail("Expected exception to be propogated");
            }
            catch (NoSuchElementException)
            {
                // Fine
            }

            Assert.IsTrue(log.ToString().Contains(exception.Message));
        }
Beispiel #7
0
        public void ShouldCallListenerOnException()
        {
            NoSuchElementException exception = new NoSuchElementException("argh");

            mockDriver.Setup(_ => _.FindElement(It.Is <By>(x => x.Equals(By.Id("foo"))))).Throws(exception);

            EventFiringWebDriver firingDriver = new EventFiringWebDriver(mockDriver.Object);

            firingDriver.ExceptionThrown += new EventHandler <WebDriverExceptionEventArgs>(firingDriver_ExceptionThrown);

            try
            {
                firingDriver.FindElement(By.Id("foo"));
                Assert.Fail("Expected exception to be propogated");
            }
            catch (NoSuchElementException)
            {
                // Fine
            }

            Assert.IsTrue(log.ToString().Contains(exception.Message));
        }
Beispiel #8
0
        public void ShouldCallListenerOnException()
        {
            NoSuchElementException exception = new NoSuchElementException("argh");

            Expect.Once.On(mockDriver).Method("FindElement").With(By.Id("foo")).Will(Throw.Exception(exception));

            EventFiringWebDriver firingDriver = new EventFiringWebDriver(mockDriver);

            firingDriver.ExceptionThrown += new EventHandler <WebDriverExceptionEventArgs>(firingDriver_ExceptionThrown);

            try
            {
                firingDriver.FindElement(By.Id("foo"));
                Assert.Fail("Expected exception to be propogated");
            }
            catch (NoSuchElementException)
            {
                // Fine
            }

            Assert.AreEqual(exception.Message, log.ToString());
        }
 protected static void HandleNoElementException(NoSuchElementException nsee, AppiumDriver <IWebElement> driver)
 {
     HandleNoElementException(nsee, GetDeviceModel(driver), true);
 }
 protected static void HandleNoElementException(NoSuchElementException nsee, RemoteWebDriverExtended driver)
 {
     HandleNoElementException(nsee, driver, false);
 }
        public T BorrowObject(long maxWaitMillisecs)
        {
            CheckClosed();

            PooledObject <T> p = null;
            bool             blockWhenExhausted = this.blockWhenExhausted;
            bool             create;

            while (p == null)
            {
                create = false;
                if (blockWhenExhausted)
                {
                    p = idleObjects.PollFirst();
                    if (p == null)
                    {
                        create = true;
                        p      = Create();
                    }

                    if (p == null)
                    {
                        if (maxWaitMillisecs < 0)
                        {
                            p = idleObjects.TakeFirst();
                        }
                        else
                        {
                            p = idleObjects.PollFirst(TimeSpan.FromMilliseconds(maxWaitMillisecs));
                        }
                    }

                    if (p == null)
                    {
                        throw new NoSuchElementException("Timeout waiting for idle object");
                    }

                    if (!p.Allocate())
                    {
                        p = null;
                    }
                }
                else
                {
                    p = idleObjects.PollFirst();
                    if (p == null)
                    {
                        create = true;
                        p      = Create();
                    }

                    if (p == null)
                    {
                        throw new NoSuchElementException("Pool exhausted");
                    }

                    if (!p.Allocate())
                    {
                        p = null;
                    }
                }

                if (p != null)
                {
                    try
                    {
                        factory.ActivateObject(p.TheObject);
                    }
                    catch (Exception e)
                    {
                        try
                        {
                            Destroy(p);
                        }
                        catch
                        {
                            // Ignore - activation failure is more important
                        }
                        p = null;
                        if (create)
                        {
                            NoSuchElementException nsee = new NoSuchElementException(
                                "Unable to activate object", e);
                            throw nsee;
                        }
                    }

                    if (p != null && TestOnBorrow)
                    {
                        bool      validate            = false;
                        Exception validationThrowable = null;
                        try
                        {
                            validate = factory.ValidateObject(p.TheObject);
                        }
                        catch (Exception ex)
                        {
                            PoolUtils.CheckRethrow(ex);
                        }
                        if (!validate)
                        {
                            try
                            {
                                Destroy(p);
                            }
                            catch
                            {
                                // Ignore - validation failure is more important
                            }
                            p = null;
                            if (create)
                            {
                                NoSuchElementException nsee = new NoSuchElementException(
                                    "Unable to validate object", validationThrowable);
                                throw nsee;
                            }
                        }
                    }
                }
            }

            return(p.TheObject);
        }
Beispiel #12
0
        public static void ThrowShouldBeAssignableToException(string reason)
        {
            var err = new NoSuchElementException();

            err.Should().BeAssignableTo <ExpectedConditions>(reason);
        }