Beispiel #1
0
 /// <summary>
 /// Test: Correct name, incorrect email and incorrect message
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="baseURL"></param>
 public void TestCorrectContact(IWebDriver driver, string baseURL, ExtentTest test)
 {
     try
     {
         driver.Navigate().GoToUrl(baseURL);
         driver.Navigate().GoToUrl(baseURL + "/");
         string id = this.iHelperSelenium.FindId(driver, "menu", "Contact");
         this.iHelperSelenium.TryClick(driver, id);
         this.iHelperSelenium.TryClear(driver, "//div[@id='ContactNameBox']/input");
         this.iHelperSelenium.TrySendKeys(driver, "//div[@id='ContactNameBox']/input", "j.Bloggs");
         this.iHelperSelenium.TryClear(driver, "//div[@id='ContactEmailBox']/input");
         this.iHelperSelenium.TrySendKeys(driver, "//div[@id='ContactEmailBox']/input", "*****@*****.**");
         this.iHelperSelenium.TryClear(driver, "//div[@id='ContactMessageBox']/textarea");
         this.iHelperSelenium.TrySendKeys(driver, "//div[@id='ContactMessageBox']/textarea", "please contact me I want to find out more");
         test.Log(LogStatus.Info, "Before sending correct Contact", test.AddScreenCapture(this.iHelperSelenium.CreatePhoto(driver)));
         this.iHelperSelenium.TryClick(driver, "//div[@id='ContactSend']/input");
         test.Log(LogStatus.Info, "Result, after sending correct Contact", test.AddScreenCapture(this.iHelperSelenium.CreatePhoto(driver)));
         driver.FindElement(By.XPath("//div[@id='ContactSend']/input"));
         test.Log(LogStatus.Pass, "Pass");
     }
     catch
     {
         test.Log(LogStatus.Fail, "Fail");
     }
 }
Beispiel #2
0
        public static void ProcesSpecFlowReports(string status, string failedtestcase, string scenarioname)
        {
            LogStatus logstatus;

            if (Settings.EnableReport == "Yes")
            {
                if (status == null)
                {
                    logstatus = LogStatus.Pass;
                }
                else
                {
                    logstatus = LogStatus.Fail;
                }


                if (logstatus == LogStatus.Fail)
                {
                    var failedimage = _test.AddScreenCapture(failedtestcase);
                    _test.Log(logstatus, scenarioname, failedimage);
                }
                else
                {
                    scenarioname = null;
                    _test.Log(logstatus, scenarioname + logstatus);
                }

                _extent.EndTest(_test);
            }
        }
Beispiel #3
0
        public static void ReportLog(ExtentTest test, string status, string Description, IWebDriver driver = null)
        {
            switch (status)
            {
            case "Pass":
                string filenamepass = Path.GetRandomFileName();
                screenshots.takescreenshot(filenamepass, driver);
                test.Log(LogStatus.Pass, Description, test.AddScreenCapture(MyPath.screenshotpath + filenamepass + ".jpeg"));
                break;

            case "Fail":
                string filename = Path.GetRandomFileName();
                screenshots.takescreenshot(filename, driver);
                test.Log(LogStatus.Fail, Description, test.AddScreenCapture(MyPath.screenshotpath + filename + ".jpeg"));
                break;

            case "Error":
                string filenameError = Path.GetRandomFileName();
                screenshots.takescreenshot(filenameError, driver);
                test.Log(LogStatus.Error, Description, test.AddScreenCapture(MyPath.screenshotpath + filenameError + ".jpeg"));
                break;

            case "Info":
                string filenameInfo = Path.GetRandomFileName();
                screenshots.takescreenshot(filenameInfo, driver);
                test.Log(LogStatus.Info, Description, test.AddScreenCapture(MyPath.screenshotpath + filenameInfo + ".jpeg"));
                break;
            }
        }
Beispiel #4
0
 /// <summary>
 /// Test: Incorrect name, incorrect email and incorrect message
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="baseURL"></param>
 public void TestIncorrectContact(IWebDriver driver, string baseURL, ExtentTest test)
 {
     try
     {
         driver.Navigate().GoToUrl(baseURL);
         driver.Navigate().GoToUrl(baseURL + "/");
         string id = this.iHelperSelenium.FindId(driver, "menu", "Contact");
         this.iHelperSelenium.TryClick(driver, id);
         this.iHelperSelenium.TryClear(driver, "//div[@id='ContactNameBox']/input");
         this.iHelperSelenium.TrySendKeys(driver, "//div[@id='ContactNameBox']/input", "addgdfg");
         this.iHelperSelenium.TryClear(driver, "//div[@id='ContactEmailBox']/input");
         this.iHelperSelenium.TrySendKeys(driver, "//div[@id='ContactEmailBox']/input", "addgdfg");
         this.iHelperSelenium.TryClear(driver, "//div[@id='ContactMessageBox']/textarea");
         this.iHelperSelenium.TrySendKeys(driver, "//div[@id='ContactMessageBox']/textarea", "addgdfg");
         test.Log(LogStatus.Info, "Before sending incorrect Contact", test.AddScreenCapture(this.iHelperSelenium.CreatePhoto(driver)));
         this.iHelperSelenium.TryClick(driver, "//div[@id='ContactSend']/input");
         test.Log(LogStatus.Info, "Result, after sending incorrect Contact", test.AddScreenCapture(this.iHelperSelenium.CreatePhoto(driver)));
         id = this.iHelperSelenium.FindId(driver, "ContactEmailBox", "Invalid Email Address");
         this.iHelperSelenium.TryFind(driver, id);
         test.Log(LogStatus.Pass, "Pass");
     }
     catch
     {
         test.Log(LogStatus.Fail, "Fail");
     }
 }
Beispiel #5
0
        //Take Screenshot and update test step status in the HTML report
        public void takeScreenshot(string filename, string stepdesc, string Result)
        {
            var ScrShot = _driver.GetScreenshot();

            ScrShot.SaveAsFile("C:\\FlightBook\\Images\\" + filename + ".jpg", ScreenshotImageFormat.Jpeg);

            if (Result == "pass")
            {
                test.Log(LogStatus.Pass, stepdesc + test.AddScreenCapture("C:\\FlightBook\\Images\\" + filename + ".jpg"));
            }
            else
            {
                test.Log(LogStatus.Fail, stepdesc + test.AddScreenCapture("C:\\FlightBook\\Images\\" + filename + ".jpg"));
            }
        }
Beispiel #6
0
        public void TestMethod()
        {
            ExtentTest test = extent.StartTest("Test A", "Sample Description");

            test.Log(LogStatus.Info, "Validating the download link");

            IWebDriver driver = new FirefoxDriver();

            try
            {
                driver.Url = "http://www.seleniumhq.org/";
                driver.Manage().Window.Maximize();
                IWebElement element = driver.FindElement(By.XPath(".//li[@id='menu_downloa']"));
                element.Click();
            }
            catch (Exception e)
            {
                TakeScreenshot("Error Screenshot", driver);
                test.Log(LogStatus.Info, "Screenshot - " + test.AddScreenCapture("D:\\Загрузки\\Error Screenshot.gif"));
                test.Log(LogStatus.Fail, e.Message);

                extent.EndTest(test);
                extent.Flush();

                driver.Quit();
            }
        }
        public IWebDriver enterEmailAddress(UserData item, IWebDriver driver, ExtentTest test)
        {
            try
            {
                test.Log(LogStatus.Info, "Entering Email Address in Sign In Page");
                test.Log(LogStatus.Info, "Email Id : " + item.email);


                utility.verifyButtonOrLinkText(createAccountButton, driver);
                email.SendKeys(item.email);
                createAccountButton.Click();

                //var errMsg = utility.getErrorMessages()
                //Boolean verifiedText = utility.verifyText("Your personal information", driver);
            }
            catch (Exception e)
            {
                // Screenshot to be attached
                utility.takeScreenshot(driver, "TC_001");
                test.Log(LogStatus.Info, "Snapshot below: " + test.AddScreenCapture(Constants.SCREENSHOT_PATH + "TC_001.png"));
                test.Log(LogStatus.Fail, "Failed in Sign In Page");
                test.Log(LogStatus.Error, e);
                Console.WriteLine(e);
            }

            return(driver);
        }
        public void GetResult()
        {
            var status       = TestContext.CurrentContext.Result.Outcome.Status;
            var stackTrace   = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>";
            var errorMessage = TestContext.CurrentContext.Result.Message;
            var testname     = TestContext.CurrentContext.Test.Name;

            //utilities.ConsoleMessageClose();
            ConsoleMessageClose();
            var fileStream = new FileStream(TextFilePath, FileMode.Open, FileAccess.Read);

            using (var streamReader = new StreamReader(fileStream, Encoding.UTF8))
            {
                result = streamReader.ReadToEnd();
            }

            if (status == TestStatus.Failed)
            {
                string screenshotpath = Capture("ScreenshotName", testname);
                extenttest.Log(LogStatus.Fail, stackTrace + errorMessage);
                extenttest.Log(LogStatus.Info, result);
                extenttest.Log(LogStatus.Fail, extenttest.AddScreenCapture(screenshotpath));
                extent.EndTest(extenttest);
            }
            else
            {
                extenttest.Log(LogStatus.Info, result);
                extent.EndTest(extenttest);
            }
        }
Beispiel #9
0
        /// <summary>
        /// Takes screenshot without scrolling in Png format
        /// </summary>
        public static void TakeScreenShot(string fileName)
        {
            Screenshot scrnsht = scrnDriver.GetScreenshot();

            scrnsht.SaveAsFile(folder_Path + "\\" + fileName, ScreenshotImageFormat.Jpeg);
            test.Log(LogStatus.Info, "Screenshot :" + test.AddScreenCapture(folder_Path + "\\" + fileName));
        }
        public void BaseCleanup()
        {
            var status     = TestContext.CurrentContext.Result.Outcome.Status;
            var stacktrace = string.IsNullOrEmpty(TestContext.CurrentContext.Result.StackTrace)
                    ? ""
                    : string.Format("<pre>{0}</pre>", TestContext.CurrentContext.Result.Message);
            LogStatus logstatus;

            switch (status)
            {
            case TestStatus.Failed:
                logstatus = LogStatus.Fail;
                string screenName     = ScreenshotHelper.TakeScreenshot();
                string screenshotPath = TestLog.AddScreenCapture("screenshots//" + screenName);
                TestLog.Log(LogStatus.Fail, "Screenshot on Fail", screenshotPath);
                break;

            case TestStatus.Inconclusive:
                logstatus = LogStatus.Warning;
                TestLog.Log(LogStatus.Warning, "Warning");
                break;

            case TestStatus.Skipped:
                logstatus = LogStatus.Skip;
                break;

            default:
                logstatus = LogStatus.Pass;
                break;
            }
            Browser.Close();
            TestLog.Log(logstatus, "Test ended with <b>" + logstatus + stacktrace);
            ReportLog.EndTest(TestLog);
            ReportLog.Flush();
        }
        public static void Capture_Screenshot(String filename, String Resultstatus, String Message)
        {
            //var location = screenshotpath +""+ filename+"_" + DateTime.Now + ".png";
            var location   = ScreenshotPath + "\\" + filename + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";
            var ssdriver   = driver as ITakesScreenshot;
            var screenshot = ssdriver.GetScreenshot();

            screenshot.SaveAsFile(location, ImageFormat.Png);
            if (Resultstatus.ToLower() == "fail")
            {
                extentTest.Log(LogStatus.Fail, Message + " " + extentTest.AddScreenCapture(location));
            }
            else
            {
                extentTest.Log(LogStatus.Pass, Message + " " + extentTest.AddScreenCapture(location));
            }
        }
Beispiel #12
0
        public void BeginExecution()
        {
            Resultspath = "C:\\CXA_Automation\\CXAPortal\\TestResults\\SmokeTest\\SmokeTest_" + DateTime.Now.ToString("ddMMyyyyHHmmss");
            CreateDirectory(Resultspath);
            ExtentReports extent = new ExtentReports(Resultspath + "\\TestReports.html", DisplayOrder.OldestFirst);

            extent.LoadConfig("C:\\CXA_Automation\\CXAPortal\\extent-config.xml");



            // Start the test using the ExtentTest class object.
            ExtentTest extentTest = extent.StartTest("My First Test",
                                                     "Verify WebSite Title");

            // Launch the FireFox browser.
            driver = new ChromeDriver();

            driver.Manage().Window.Maximize();

            extentTest.Log(LogStatus.Info, "Browser Launched");

            // Open application.

            driver.Navigate().GoToUrl("https://flex-api.cxanow.com/Default.aspx?Msg=CookieIsRequired");

            extentTest.Log(LogStatus.Info, "Navigated to CXAPOrtal Page ");

            // get title.
            // String title = driver.Title;

            extentTest.Log(LogStatus.Info, "Get the WebSite title");

            // Verify title.
            //  Assert.IsTrue(title.Contains("Selenium Webdriver"));

            extentTest.Log(LogStatus.Pass, "Title verified");

            // In case you want to attach screenshot then use below method
            // We used a random image but you've to take screenshot at run-time
            // and specify the error image path.
            String loc = Take_Screenshot("Revanth");

            extentTest.Log(
                LogStatus.Info,
                "Error Snapshot : "
                + extentTest.AddScreenCapture(loc));

            // Close application.
            // driver.quit();

            extentTest.Log(LogStatus.Info, "Browser closed");

            // close report.
            extent.EndTest(extentTest);

            // writing everything to document.
            extent.Flush();
        }
 public static void FailReporter(IWebDriver driver, ExtentTest test, string Step_Description, string Expected, string Status)
 {
     if (Expected.Length != 0)
     {
         test.Log(LogStatus.Fail, Expected);
     }
     test.Log(LogStatus.Fail, test.AddScreenCapture(TakeScreenShort(driver)));
     Excel_Libraries.CreateExcel(Step_Description, Expected, Status, DateTime.Now.ToString());
 }
Beispiel #14
0
        public static void PrintScreen(this IWebDriver driver)
        {
            string     imgName = String.Format("{0}\\{1}.png", imgPath, DateTime.Now.ToString("yyyyMMdd-HHmmss"));
            Screenshot ss      = ((ITakesScreenshot)driver).GetScreenshot();

            ss.SaveAsFile(imgName, System.Drawing.Imaging.ImageFormat.Png);

            test.Log(LogStatus.Info, "Please see screenshot below: " + test.AddScreenCapture(imgName));
        }
        [DataSource("System.Data.Odbc", "Dsn=Excel Files;dbq=|DataDirectory|\\TestData\\Test.xlsx;defaultdir=.;driverid=1046;maxbuffersize=2048;pagetimeout=5", "Sheet1$", DataAccessMethod.Sequential), TestMethod]//[DataSource("System.Data.Odbc", "Dsn=ExcelFiles;Driver={Microsoft Excel Driver (*.xlsx)};dbq=|DataDirectory|\\Test.xlsx;defaultdir=.;driverid=1046;maxbuffersize=2048;pagetimeout=5;readonly=true", "Sheet1$", DataAccessMethod.Sequential), DeploymentItem("Test.xlsx"), TestMethod]//[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\TestData\\TestData.csv", "TestData#csv", DataAccessMethod.Sequential), DeploymentItem("TestData.csv"), TestMethod]//[DataSource("System.Data.Odbc", "Dsn=Excel Files;dbq=C:\\Test.xlsx;defaultdir=.;driverid=1046;maxbuffersize=2048;pagetimeout=5", "Sheet1$", DataAccessMethod.Sequential), TestMethod]
        public void NewTest()
        {
            //objHTMLControl.clickHTMLHyperlinkOneProp("Test");
            //objHTMLControl.clickHTMLHyperlinkOneProp("Contact");
            objReport.CreateScreenshotSubFolders(testContextInstance.TestName, TestContext.DataRow.Table.Rows.IndexOf(TestContext.DataRow).ToString());
            string strValue = TestContext.DataRow["Test"].ToString();

            if (strValue == "1")
            {
                Console.WriteLine("Pass");
                test.Log(LogStatus.Pass, test.AddScreenCapture(objReport.ScreenshotPass("Test Passed")));
            }
            else
            {
                test.Log(LogStatus.Fail, test.AddScreenCapture(objReport.ScreenshotFail("Test Failed")));
                Assert.Fail("Failed");
            }
        }
Beispiel #16
0
        public void FinalizeTest()
        {
            try
            {
                if (ExtentManager.Instance == null)
                {
                    return;
                }

                var    status         = TestContext.CurrentContext.Result.Outcome.Status;
                string screenShotPath = null;

                LogStatus logStatus;

                switch (status)
                {
                case TestStatus.Failed:
                    logStatus = LogStatus.Fail;

                    var stackTrace   = "" + TestContext.CurrentContext.Result.StackTrace + "";
                    var errorMessage = TestContext.CurrentContext.Result.Message;

                    screenShotPath = ReportHelper.Capture(_driver, TestContext.CurrentContext.Test.MethodName);

                    _test.Log(logStatus, "Test ended with " + logStatus + " ---------- " + errorMessage);
                    _test.Log(logStatus, "Snapshot below: " + _test.AddScreenCapture(screenShotPath));

                    break;

                case TestStatus.Skipped:
                    logStatus = LogStatus.Skip;

                    break;

                default:
                    logStatus = LogStatus.Pass;

                    _test.Log(logStatus, "Test ended with " + logStatus);

                    break;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
            finally
            {
                if (_driver != null)
                {
                    _driver.Quit();
                }

                _extent.EndTest(_test);
                _extent.Flush();
            }
        }
Beispiel #17
0
        public static void GenerateScreenshot()
        {
            screenshot = ((ITakesScreenshot)driver).GetScreenshot();
            string pathImage = Path.Combine(ValidationPathFolders(Path.Combine(pathProjetc, "Evidências", dateTime)), "Imagem_" + DateTime.Now.ToString("ddMMyyyyThhmmss") + ".png");

            screenshot.SaveAsFile(pathImage, ScreenshotImageFormat.Png);

            image = test.AddScreenCapture(pathImage);
        }
        public void takeScreenShot()
        {
            Screenshot screen      = driver.TakeScreenshot();
            string     filname     = DateTime.UtcNow.ToString("yyyy-MM-dd-mm-ss") + ".jpeg";
            string     capturepath = @"D:\Selenium\ExtentReports\ScreenShots\" + filname;

            screen.SaveAsFile(capturepath, ScreenshotImageFormat.Png);
            test.Log(LogStatus.Info, test.AddScreenCapture(capturepath));
        }
        public void validateCreateContact()
        {
            logger.Log(LogStatus.Info, "Starting Test");

            homepage.clickonContactsLink();
            Thread.Sleep(2500);
            contactspage.createNewContact("Contacts");


            logger.Log(LogStatus.Pass, logger.AddScreenCapture(testutil.TakeScreenshot(driver, "CreateNewContact")));
        }
Beispiel #20
0
 public void ClickAboutPageLink()
 {
     try
     {
         AboutPageLink.Click();
     }
     catch (Exception ex)
     {
         extentReportsTest.Log(LogStatus.Error, "Exception: {0}", Details: ex.Message);
         extentReportsTest.AddScreenCapture(projectPath);
     }
 }
Beispiel #21
0
        public static void GetResult()
        {
            var status     = TestContext.CurrentContext.Result.Outcome.Status;
            var stackTrace = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>";


            if (status == TestStatus.Failed)
            {
                string screenShotPath = GetScreenshot.Capture(driver, "ScreenShotName");
                test.Log(LogStatus.Fail, "Snapshot below: " + test.AddScreenCapture(screenShotPath));
            }
        }
        private static string RunTest(ExtentTest test)
        {
            Driver.Url = baseUrl;
            AssertTitle("stuff that matters", test);
            try
            {
                var articles = Driver.FindElements(By.CssSelector(@"span[class='story-title']"));
                test.Log(LogStatus.Info, "Print articles qty on the page ", articles.Count.ToString());
                var           allIcons  = Driver.FindElements(By.CssSelector(@"span[class='topic'] > a >img"));
                List <string> allTitles =
                    allIcons.ToList().ConvertAll(x => x.GetAttribute("title")).ToList();
                var uniqueIcons =
                    from title in allTitles
                    group title by title into t
                    select new { value = t.Key, count = t.Count() };
                foreach (var t in uniqueIcons)
                {
                    // Print a list of unique (different) icons used on article titles and how many times was it used
                    test.Log(LogStatus.Info, "Unique icon title: " + t.value, "Used times: " + t.count.ToString());
                }

                IWebElement   form   = Driver.FindElement(By.Id("pollBooth"));
                IWebElement[] labels = Driver.FindElements(By.CssSelector(@"form#pollBooth>label")).ToArray();

                // pickup a random option (label)
                Random rand  = new Random();
                int    index = rand.Next(0, labels.Length);

                labels[index].Click();
                string optionText = labels[index].Text;
                // Vote for some random option on the daily poll
                form.Submit();

                WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(3));
                wait.Until(d => d.FindElement(By.CssSelector("div[class='poll-bar-label']")));

                AssertTitle("humans discover life on another ...", test);
                string[] labelTexts = Driver.FindElements(By.CssSelector("div[class='poll-bar-label']")).ToList().ConvertAll(x => x.Text).ToArray();
                string[] labelVotes = Driver.FindElements(By.CssSelector("div[class='poll-bar-group']>div>div>div")).ToList().ConvertAll(x => x.Text.Split()[0]).ToArray();

                string optionVotes = labelVotes[Array.IndexOf(labelTexts, optionText)];
                TakeScreenshot(Driver, screenshotLocation);
                _test.Log(LogStatus.Info, "Screenshot - " + _test.AddScreenCapture(screenshotLocation)); // add screenshot

                // Return the number of people that have voted for that same option
                return(optionVotes);
            }
            catch (Exception e)
            {
                test.Log(LogStatus.Error, "Exception occurred: ", e.Message);
                return(string.Empty);
            }
        }
Beispiel #23
0
 public void LogReport(Boolean result, ExtentTest test, String stepName, String details)
 {
     if (result == true)
     {
         test.Log(LogStatus.Pass, stepName, details);
     }
     else
     {
         //imageFile = CaptureScreenShot();
         test.Log(LogStatus.Fail, test.AddScreenCapture(TakeErrorScreenShot(stepName)) + stepName + " - is Failed");
     }
 }
Beispiel #24
0
        public IWebDriver enterUserDetails(UserData item, Utility utility, IWebDriver driver, ExtentTest test)
        {
            try
            {
                /*Boolean verifiedText = utility.verifyText("Your personal information", driver);
                 * if (verifiedText)
                 * {
                 *  Console.WriteLine("Account Creation Page Loaded successfully");
                 * }
                 * else
                 * {
                 *  Console.WriteLine("Could Not Find Account Creation Page");
                 * }*/
                utility.verifyButtonOrLinkText(registerButton, driver);
                // Display messages....
                title.Click();
                firstName.SendKeys(item.firstName);
                lastName.SendKeys(item.lastName);
                password.SendKeys(item.password);
                date.SendKeys(item.date_DOB);
                month.SendKeys(item.month_DOB);
                year.SendKeys(item.year_DOB);
                mobileNum.SendKeys(item.mobileNumber);
                address.SendKeys(item.address);
                city.SendKeys(item.city);
                state.SendKeys(item.state);
                postalCode.SendKeys(item.postalCode);
                addressAlias.Clear();
                addressAlias.SendKeys(item.address);
                registerButton.Click();

                /*if (item.errorMessages)
                 * {
                 * String[] errormessages = utility.getErrorMessages(errorMessages);
                 *
                 *  for(i=0; item < errormessages.Length();i++) {
                 *      utility.verifyText(errormessages[i]);
                 *  }
                 * }  */
            }
            catch (Exception e)
            {
                utility.takeScreenshot(driver, "TC_001");
                test.Log(LogStatus.Info, "Snapshot below: " + test.AddScreenCapture(Constants.SCREENSHOT_PATH + "TC_001.png"));
                test.Log(LogStatus.Fail, "Failed in Sign In Page");
                test.Log(LogStatus.Error, e);
                Console.WriteLine(e);
                Console.WriteLine(e);
            }

            return(driver);
        }
Beispiel #25
0
 /// <summary>
 /// This method allow us add the screenshot in the test cases when the step is failed
 /// </summary>
 private void AddPicturesOnFail()
 {
     try
     {
         var tcFolder = ConfigurationVariable.ScreenPath;
         _currentTestCase.Log(LogStatus.Error,
                              _currentTestCase.AddScreenCapture(tcFolder));
     }
     catch (Exception ex)
     {
         LoggerManagerClass.Instance.Error(ex.Message);
     }
 }
Beispiel #26
0
        public void AfterMethod()
        {
            var status       = TestContext.CurrentContext.Result.Outcome.Status;
            var stackTrace   = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>";
            var errorMessage = TestContext.CurrentContext.Result.Message;

            if (status == TestStatus.Failed)
            {
                string screenShotPath = GetScreenShot.Capture(driver, "ScreenShotName");
                test.Log(LogStatus.Fail, stackTrace + errorMessage);
                test.Log(LogStatus.Fail, "Snapshot below: " + test.AddScreenCapture(screenShotPath));
            }
            extent.EndTest(test);
        }
Beispiel #27
0
        public void TearDown()
        {
            // Screenshot
            String img = SaveScreenShotClass.SaveScreenshot(driver, "Report");//AddScreenCapture(@"E:\Dropbox\VisualStudio\Projects\Beehive\TestReports\ScreenShots\");

            test.Log(LogStatus.Info, "Snapshot below: " + test.AddScreenCapture(img));
            // end test. (Reports)
            extent.EndTest(test);
            // calling Flush writes everything to the log file (Reports)
            extent.Flush();
            // Close the driver :)
            driver.Close();
            driver.Quit();
        }
        public void TearDown()
        {
            // Screenshot
            String img = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Report");

            test.Log(LogStatus.Fail, "Snapshot below: " + test.AddScreenCapture(img));
            // end test. (Reports)
            extent.EndTest(test);
            // calling Flush writes everything to the log file (Reports)

            Thread.Sleep(3500);
            // Close the driver
            GlobalDefinitions.driver.Close();
        }
Beispiel #29
0
        public void TearDown()
        {
            //Get test restult
            var status       = TestContext.CurrentContext.Result.Outcome.Status;
            var stacktrace   = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>";
            var errorMessage = TestContext.CurrentContext.Result.Message;

            // Screenshot
            string screenShotPath = SaveScreenShotClass.SaveScreenshot(Driver, TestContext.CurrentContext.Test.Name);

            // Write log to report
            LogStatus logstatus;

            switch (status)
            {
            case TestStatus.Failed:
                logstatus = LogStatus.Fail;
                test.Log(logstatus, "Test ended with " + logstatus + "–" + stacktrace + errorMessage);
                test.Log(LogStatus.Info, "Snapshot below:" + test.AddScreenCapture(screenShotPath));
                break;

            case TestStatus.Passed:
                logstatus = LogStatus.Pass;
                test.Log(logstatus, "Test ended with " + logstatus);
                test.Log(LogStatus.Info, "Snapshot below:" + test.AddScreenCapture(screenShotPath));
                break;
            }

            // end test. (Reports)
            extent.EndTest(test);
            // calling Flush writes everything to the log file (Reports)
            extent.Flush();
            // Close the driver
            Driver.Close();
            Driver.Quit();
        }
Beispiel #30
0
        public void TearDown()
        {
            Thread.Sleep(500);
            // Screenshot
            String img = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Report");//AddScreenCapture(@"E:\Dropbox\VisualStudio\Projects\Beehive\TestReports\ScreenShots\");

            GlobalDefinitions.test.Log(LogStatus.Info, "Image example: " + test.AddScreenCapture(img));
            // end test. (Reports)
            GlobalDefinitions.extent.EndTest(GlobalDefinitions.test);
            // calling Flush writes everything to the log file (Reports)
            extent.Flush();
            // Close the driver :)
            GlobalDefinitions.driver.Close();
            GlobalDefinitions.driver.Quit();
        }