Ejemplo n.º 1
0
        /// <summary>
        /// Take screenshot if test failed and delete cached page objects.
        /// </summary>
        /// <param name="driverContext">The driver context.</param>
        /// <returns>The saved attachements, null if not found.</returns>
        public string[] SaveTestDetailsIfTestFailed(DriverContext driverContext)
        {
            try
            {
                var returnList = new List <string>();
                if (driverContext.IsTestFailed)
                {
                    var screenshots = driverContext.TakeAndSaveScreenshot();
                    ////var pageSource = this.SavePageSource(driverContext);
                    returnList.AddRange(screenshots);
                    ////if (pageSource != null)
                    ////{
                    ////    returnList.Add(pageSource);
                    ////}

                    return(returnList.ToArray());
                }

                return(returnList.ToArray());
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Verify group of assets
        /// </summary>
        /// <param name="driverContext">Container for driver</param>
        /// <param name="enableScreenShot">Enable screenshot</param>
        /// <param name="enableSavePageSource">Enable save page source</param>
        /// <param name="myAsserts">Group asserts</param>
        /// <example>How to use it: <code>
        /// Verify.That(
        ///     this.DriverContext,
        ///     true,
        ///     false,
        ///     () => Assert.AreEqual(5 + 7 + 2, forgotPassword.EnterEmail(5, 7, 2)),
        ///     () => Assert.AreEqual("Your e-mail's been sent!", forgotPassword.ClickRetrievePassword));
        /// </code></example>
        public static void That(DriverContext driverContext, bool enableScreenShot, bool enableSavePageSource, params Action[] myAsserts)
        {
            foreach (var myAssert in myAsserts)
            {
                That(driverContext, myAssert, false, false);
            }

            if (!driverContext.VerifyMessages.Count.Equals(0) && enableScreenShot)
            {
                driverContext.TakeAndSaveScreenshot();
            }

            if (!driverContext.VerifyMessages.Count.Equals(0) && enableSavePageSource)
            {
                driverContext.SavePageSource(driverContext.TestTitle);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Take screenshot if test failed and delete cached page objects.
        /// </summary>
        /// <param name="driverContext">The driver context.</param>
        /// <returns>The saved attachements, null if not found.</returns>
        public string[] SaveTestDetailsIfTestFailed(DriverContext driverContext)
        {
            if (driverContext.IsTestFailed)
            {
                var screenshots = driverContext.TakeAndSaveScreenshot();
                var pageSource  = this.SavePageSource(driverContext);

                var returnList = new List <string>();
                returnList.AddRange(screenshots);
                if (pageSource != null)
                {
                    returnList.Add(pageSource);
                }

                return(returnList.ToArray());
            }

            return(null);
        }
Ejemplo n.º 4
0
        public static void That(DriverContext driverContext, Action myAssert, bool enableScreenShot, bool enableSavePageSource)
        {
            try
            {
                myAssert();
            }
            catch (Exception e)
            {
                if (enableScreenShot)
                {
                    driverContext.TakeAndSaveScreenshot();
                }

                if (enableSavePageSource)
                {
                    driverContext.SavePageSource(driverContext.TestTitle);
                }

                driverContext.VerifyMessages.Add(new ErrorDetail(null, DateTime.Now, e));

                Logger.Error(CultureInfo.CurrentCulture, "<VERIFY FAILS>\n{0}\n</VERIFY FAILS>", e);
            }
        }