public void getResult()
        {
            TestStatus s = TestContext.CurrentContext.Result.Outcome.Status;

            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)
            {
                // Take screen shot of the curent page

                string screenShotPath = GetScreenShot.Capture(Browser.driver, getDateTime());

                // GetScreenShot.GetEntereScreenshot(Browser.driver, "screenShotName");
                test.Log(Status.Fail, MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name + " Test case FAILED due to below issues:", ExtentColor.Red));
                test.Fail(TestContext.CurrentContext.Result.Message);

                test.Log(Status.Fail, stackTrace + errorMessage);
                test.Log(Status.Fail, "Snapshot below: " + test.AddScreenCaptureFromPath(screenShotPath));
            }
            else if (status == TestStatus.Passed)
            {
                test.Log(Status.Pass, MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name + " Test Case PASSED", ExtentColor.Green));
            }
            else
            {
                test.Log(Status.Skip, MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name + " Test Case SKIPPED", ExtentColor.Orange));
                test.Skip(TestContext.CurrentContext.Test.FullName);
            }

            //Flush all status into Report
            extent.Flush();
        }
Example #2
0
        public static ExtentTest CreateTestwrap(string description)
        {
            test = extent.CreateTest(description, "");
            IMarkup m = MarkupHelper.CreateLabel(description, ExtentColor.Red);

            return(test);
        }
Example #3
0
        public void EditUserFunc(String searchtext, IWebElement UserEmailTextBox, String value, IWebElement dropdownelement, IWebElement ddlistbox, int ddloption, IWebElement FirstName, String fnamevalue, IWebElement LastName, String lnamevalue, IWebElement IsUserActiveFlag, IWebElement SaveUserBtn)
        {
            DriverUtils.LaunchBrowser("http://cos-test.psr.rd.hpicorp.net/COSWeb/ManageUser/UserManagement");
            SearchTextBox.EnterText(searchtext);

            if (!string.IsNullOrEmpty(ManageUsersTableRow.Text) && (!string.IsNullOrWhiteSpace(ManageUsersTableRow.Text) && ManageUsersTableRow.Text.Contains(searchtext)))
            {
                Console.WriteLine("User data exist in the table" + ManageUsersTableRow.Text);
                EditUserBtn.Click();
                UserEmailTextBox.EnterText(value);
                BasicMethods.DropDownFunction(dropdownelement, ddlistbox, ddloption);
                FirstName.EnterText(fnamevalue);
                LastName.EnterText(lnamevalue);
                IsUserActiveFlag.Click();
                SaveUserBtn.Click();
                Thread.Sleep(8000);
                //CreateUserCloseBtn.Click();
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "Updated User Information!!");
            }
            else
            {
                string s = BasicMethods.TakeScreenShot();
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("No record found", ExtentColor.Red)).AddScreenCaptureFromPath(s);
            }
        }
Example #4
0
        public void ExtentFlush()
        {
            test = extent.CreateTest(TestContext.CurrentContext.Test.Name).Info("Test Started");
            var error = TestContext.CurrentContext.Result.Message;

            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
            {
                test.Log(Status.Info, error);
                string path = Screenshot.Capture(driver, TestContext.CurrentContext.Test.Name + "   " + "Failed");
                test.AddScreenCaptureFromPath(path);
                test.Fail(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Red));
                test.Log(Status.Fail, "Test Failed");
                log.Error("Test Failed");
                SendEmailMain.SendEmail(error, TestContext.CurrentContext.Result.StackTrace);
            }
            else if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed)
            {
                string path = Screenshot.Capture(driver, TestContext.CurrentContext.Test.Name);
                test.AddScreenCaptureFromPath(path);
                test.Pass(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Green));
                test.Log(Status.Pass, "Test pass");
            }
            driver.Navigate().Refresh(); // every test must refresh the webpage ..use in negative test
            extent.Flush();
        }
 public void WARNING(string content)
 {
     if (getreport)
     {
         _extentTObj.Warning(MarkupHelper.CreateLabel(content, ExtentColor.Orange));
     }
 }
        public void TestMethod()
        {
            //To create report object
            var htmlReporter = new ExtentHtmlReporter("E:\\Test.html");
            var extent       = new ExtentReports();

            extent.AttachReporter(htmlReporter);
            ExtentTest testlog;

            //Represents HTML log
            testlog = extent.CreateTest("Test Log Method-2", "<br/>"
                                        + "Lorem Ipsum is simply dummy text of the printing and typesetting industry." + "<br/><br/>"
                                        + "<b>Where can I get some?</b>" + "<br/>"
                                        + "There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.");
            testlog.Log(Status.Info, "This is Info log");
            testlog.Log(Status.Pass, "This is Pass log");
            testlog.Log(Status.Fail, "This is Fail log");

            testlog = extent.CreateTest("Test log with Extent Color");
            testlog.Log(Status.Info, MarkupHelper.CreateLabel("This is Info log", ExtentColor.Orange));
            testlog.Log(Status.Pass, MarkupHelper.CreateLabel("This is pass log", ExtentColor.Cyan));

            //If flush method did not call, Report will not generate.
            extent.Flush();
        }
Example #7
0
        public void TestMethod()
        {
            //To create report object
            var htmlReporter = new ExtentHtmlReporter("E:\\Test.html");
            var extent       = new ExtentReports();

            extent.AttachReporter(htmlReporter);
            ExtentTest testlog;
            ExtentTest childLog;

            testlog = extent.CreateTest("Test log with Child nodes");
            testlog.Log(Status.Info, MarkupHelper.CreateLabel("This is Info log", ExtentColor.Orange));
            testlog.Log(Status.Pass, MarkupHelper.CreateLabel("This is pass log", ExtentColor.Cyan));

            //Child test node to integrate with Parent test
            childLog = testlog.CreateNode("Childnode-1");
            childLog.Info("This is Info log");
            childLog.Pass("This is Pass log");
            childLog.Fail("This is Fail log");

            childLog = childLog.CreateNode("Childnode-2");
            childLog.Info("This is Info log");
            childLog.Pass("This is Pass log");

            childLog = testlog.CreateNode("Childnode-3");
            childLog.Info("This is Info log");
            childLog.Pass("This is Pass log");
            childLog.Warning("This is Warning log");

            extent.Flush();
        }
Example #8
0
 public void ExtentFlush()
 {
     try
     {
         test = extent.CreateTest(TestContext.CurrentContext.Test.Name).Info("Test Started");
         var error = TestContext.CurrentContext.Result.Message;
         if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
         {
             log.Error(TestContext.CurrentContext.Test.Name + "Failed");
             test.Log(Status.Info, error);
             string path = Screenshot.Capture(driver, TestContext.CurrentContext.Test.Name + "   " + "Failed");
             test.AddScreenCaptureFromPath(path);
             test.Fail(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Red));
             test.Log(Status.Fail, "Test Failed");
             log.Error("Test Failed");
             SendEmailMain.SendEmail(error, TestContext.CurrentContext.Result.StackTrace);
         }
         else if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed)
         {
             log.Info(TestContext.CurrentContext.Test.Name + "Passed");
             test.Pass(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Green));
             test.Log(Status.Pass, "Test pass");
             log.Info(TestContext.CurrentContext.Test.Name + "Test Completed");
         }
         extent.Flush();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
 public void ERROR(string content)
 {
     if (getreport)
     {
         _extentTObj.Error(MarkupHelper.CreateLabel(content, ExtentColor.Red));
     }
 }
 public void PASS(string content)
 {
     if (getreport)
     {
         _extentTObj.Pass(MarkupHelper.CreateLabel(content, ExtentColor.Green));
     }
 }
 ///<summary>
 ///Extent Report Logs
 ///</summary>
 public void FAIL(string content)
 {
     if (getreport)
     {
         _extentTObj.Fail(MarkupHelper.CreateLabel(content, ExtentColor.Red));
     }
 }
Example #12
0
        public void close()
        {
            try
            {
                Utility.InternetConnection();
                test = extent.CreateTest(TestContext.CurrentContext.Test.Name);
                if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
                {
                    string path = Utility.TakeScreenshot(driver, TestContext.CurrentContext.Test.Name);
                    test.Log(Status.Fail, "Test Failed");
                    test.AddScreenCaptureFromPath(path);
                    test.Fail(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Red));
                }
                else if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed)
                {
                    test.Log(Status.Pass, "Test Sucessful");
                    test.Pass(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Green));
                }

                Utility.SendEmail();
            }
            catch (Exception e)
            {
                log.Error("error: " + e);
                Console.Out.WriteLine(e.StackTrace);
                Console.Out.WriteLine(e.Message);
            }

            Thread.Sleep(5000);
            extent.Flush();
        }
Example #13
0
 public void Close()
 {
     try
     {
         test = extent.CreateTest(TestContext.CurrentContext.Test.Name);
         if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
         {
             string path = Utility.TakeScreenshot(driver, TestContext.CurrentContext.Test.Name);
             test.Log(Status.Fail, "Test Failed");
             test.AddScreenCaptureFromPath(path);
             test.Fail(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Red));
         }
         else if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed)
         {
             string path = Utility.TakeScreenshot(driver, TestContext.CurrentContext.Test.Name);
             test.Log(Status.Pass, "Test Sucessful");
             test.AddScreenCaptureFromPath(path);
             test.Pass(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Green));
         }
     }
     catch (Exception e)
     {
         throw e;
     }
     driver.Navigate().Refresh();
     Thread.Sleep(5000);
     extent.Flush();
 }
Example #14
0
        protected void TestPassed(string msg)
        {
            var markup = MarkupHelper.CreateLabel(msg, ExtentColor.Green);

            if (this.CurrentTest != null)
            {
                this.CurrentTest.Pass(markup);
            }
        }
Example #15
0
        protected void TestFail(Exception ex)
        {
            var markup = MarkupHelper.CreateLabel(ex.Message, ExtentColor.Red);

            if (this.CurrentTest != null)
            {
                this.CurrentTest.Fail(markup);
            }
        }
Example #16
0
        protected void TestInfo(string msg)
        {
            var markup = MarkupHelper.CreateLabel(msg, ExtentColor.Blue);

            if (this.CurrentTest != null)
            {
                this.CurrentTest.Info(markup);
            }
        }
Example #17
0
 public static void LogFail(ExtentTest test, string message)
 {
     test.Fail(MarkupHelper.CreateLabel(message, ExtentColor.Red));
     if (!(TestContext.CurrentContext.Result.Outcome.Status.Equals(TestStatus.Warning) ||
           TestContext.CurrentContext.Result.Outcome.Status.Equals(TestStatus.Failed)))
     {
         Assert.Fail(message);
     }
 }
Example #18
0
        private void PrintReport()
        {
            string imgpath;

            var    status     = TestContext.CurrentContext.Result.Outcome.Status;
            var    stacktrace = TestContext.CurrentContext.Result.StackTrace;
            var    message    = TestContext.CurrentContext.Result.Message;
            Status logstatus;

            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
            {
                logstatus = Status.Fail; // red cross sign before test step
                Console.WriteLine("Message : " + TestContext.CurrentContext.Result.Message);
                log.Error(TestContext.CurrentContext.Test.MethodName + " Test case fail");
                ExtentTestManager.GetTest().Log(logstatus, stacktrace + "\n" + message);
                if (is_soft_assert == false)
                {
                    if (ConfigurationManager.AppSettings["TestStatScrnshot"].ToLower() == "failed" || ConfigurationManager.AppSettings["TestStatScrnshot"].ToLower() == "both")
                    {
                        imgpath = util.TakeScreenshot(driver);
                        log.Info("Screenshot taken for failed test case : " + imgpath);
                        ExtentTestManager.GetTest().Log(logstatus, "Screenshot: \n", MediaEntityBuilder.CreateScreenCaptureFromPath(imgpath).Build());
                    }
                }
                ExtentTestManager.GetTest().Log(logstatus, MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name + " :: " + logstatus, ExtentColor.Red));
                util.WriteToFile(TestContext.CurrentContext.Test.FullName);
            }
            else if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed)
            {
                logstatus = Status.Pass;
                log.Info(TestContext.CurrentContext.Test.Name + "  Test case pass");
                if (is_soft_assert == false)
                {
                    if (ConfigurationManager.AppSettings["TestStatScrnshot"].ToLower() == "passed" || ConfigurationManager.AppSettings["TestStatScrnshot"].ToLower() == "both")
                    {
                        imgpath = util.TakeScreenshot(driver);
                        log.Info("Screenshot taken for failed test case : " + imgpath);
                        ExtentTestManager.GetTest().Log(logstatus, "Screenshot: \n", MediaEntityBuilder.CreateScreenCaptureFromPath(imgpath).Build());
                    }
                }
                ExtentTestManager.GetTest().Log(logstatus, MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name + " :: " + logstatus, ExtentColor.Green));
            }
            else if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Warning)
            {
                logstatus = Status.Warning;
                log.Warning(TestContext.CurrentContext.Test.MethodName + " Test case warn");
                ExtentTestManager.GetTest().Log(logstatus, message);
                ExtentTestManager.GetTest().Log(logstatus, MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name + " :: " + logstatus, ExtentColor.Orange));
            }
            else if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Skipped)
            {
                logstatus = Status.Skip;
                log.Info(TestContext.CurrentContext.Test.MethodName + " Test case skip");
                ExtentTestManager.GetTest().Log(logstatus, message);
                ExtentTestManager.GetTest().Log(logstatus, MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name + " :: " + logstatus, ExtentColor.Blue));
            }
        }
Example #19
0
 protected void TestError(Exception ex)
 {
     if (this.CurrentTest != null)
     {
         var markup = MarkupHelper.CreateLabel(ex.Message, ExtentColor.Red);
         var stack  = MarkupHelper.CreateCodeBlock(ex.StackTrace);
         this.CurrentTest.Error(markup);
         this.CurrentTest.Fatal(stack);
     }
 }
        public void LogUrlRequest(ExtentTest currentTest, string request, CodeLanguage codeFormat)
        {
            //Adds a label for visual purposes
            var formattedLabel = MarkupHelper.CreateLabel("Request:", ExtentColor.Lime);

            currentTest.Log(Status.Info, formattedLabel);

            //Logs the response in the codeFormat
            var formattedMessage = MarkupHelper.CreateCodeBlock(request, codeFormat);

            currentTest.Log(Status.Info, formattedMessage);
            Core.ExtentReport.Flush();
        }
Example #21
0
        public void TestMethod()
        {
            //To create report object
            var htmlReporter = new ExtentHtmlReporter("E:\\Test.html");
            var extent       = new ExtentReports();

            extent.AttachReporter(htmlReporter);
            ExtentTest extentTest;

            //To define system info
            extent.AddSystemInfo("Host Name", "Web Portal");
            extent.AddSystemInfo("Environment", "Automation Testing");
            extent.AddSystemInfo("User Name", "QA Automation");

            //To define system config
            htmlReporter.Config.Theme         = Theme.Dark;
            htmlReporter.Config.CSS           = "";
            htmlReporter.Config.ReportName    = "This is Report name";
            htmlReporter.Config.DocumentTitle = "This is Document Title";

            //Create simple logs
            extentTest = extent.CreateTest("Simple Logs");
            extentTest.Info("This is Info Log");
            extentTest.Pass("This is Pass Log");
            extentTest.Fail("This is Fail Log");
            extentTest.Fatal("This is Fatal Log");
            extentTest.Warning("This is Warning Log");

            //Create simple logs by another way
            extentTest = extent.CreateTest("Detail Logs");
            extentTest.Log(Status.Info, "This is Info Log");
            extentTest.Log(Status.Fail, "This is Fail Log");
            extentTest.Log(Status.Pass, "This is Pass Log");
            extentTest.Log(Status.Skip, "This is Skip Log");
            extentTest.Log(Status.Debug, "This is Debug Log");
            extentTest.Log(Status.Error, "This is Error Log");
            extentTest.Log(Status.Fatal, "This is Fatal Log");
            extentTest.Log(Status.Warning, "This is Warning Log");

            //Create markup logs
            extentTest = extent.CreateTest("Markup Logs");
            extentTest.Info(MarkupHelper.CreateLabel("This is Info Log", ExtentColor.Amber));
            extentTest.Pass(MarkupHelper.CreateLabel("This is Pass Log", ExtentColor.Indigo));
            extentTest.Fail(MarkupHelper.CreateLabel("This is Fail Log", ExtentColor.Purple));
            extentTest.Fatal(MarkupHelper.CreateLabel("This is Fatal Log", ExtentColor.Transparent));
            extentTest.Warning(MarkupHelper.CreateLabel("This is Warning Log", ExtentColor.Lime));

            extent.Flush();
        }
Example #22
0
 //Fucntion to check the radio button
 public static void RadioButton(this IWebElement element)
 {
     if (element.GetAttribute("checked") == "true")
     {
         Console.WriteLine("radio button is checked!");
         Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "radio button is checked!");
     }
     else
     {
         Console.WriteLine("This is one of the unchecked radio buttons!");
         Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, "This is one of the unchecked radio buttons!");
         string s = BasicMethods.TakeScreenShot();
         Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("Observed Image", ExtentColor.Red)).AddScreenCaptureFromPath(s);
     }
 }
Example #23
0
 public void CloseUp()
 {
     test = extent.CreateTest(TestContext.CurrentContext.Test.Name);
     if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
     {
         string path = Take.ScreenShots(driver, TestContext.CurrentContext.Test.Name + TestStatus.Failed);
         test.Log(Status.Fail, "Test Failed");
         test.AddScreenCaptureFromPath(path);
         test.Fail(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Red));
     }
     else if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed)
     {
         test.Log(Status.Pass, "Test Sucessful");
         test.Pass(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Green));
     }
     extent.Flush();
 }
Example #24
0
        //Image Verification function
        public static void CheckImage(this IWebElement element)
        {
            IWebElement ImageFile    = element;
            Boolean     ImagePresent = (Boolean)((IJavaScriptExecutor)DriverUtils.driver).ExecuteScript("return arguments[0].complete && typeof arguments[0].naturalWidth != \"undefined\" && arguments[0].naturalWidth > 0", ImageFile);

            if (ImagePresent)
            {
                Console.WriteLine("Image displayed.");
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "Image exist");
            }
            else
            {
                Console.WriteLine("Image not displayed.");
                string s = BasicMethods.TakeScreenShot();
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("Image is missing", ExtentColor.Red)).AddScreenCaptureFromPath(s);
            }
        }
Example #25
0
        public void NavigateToSpecification()
        {
            test = LoadHtmlFile.CreateTestwrap("create a product for RSC product style ");
            test.Log(Status.Warning, "This is the final Log");
            LoadHtmlFile.SetupReporting("D:\\Nunit_Workspace\\NUnitSamplec\\NUnitSample\\Reports\\SampleFile1.html");
            test.Log(Status.Pass, MarkupHelper.CreateLabel("Manoj" + " Test Case PASSED", ExtentColor.Green));
            driver.Url = PropertyReader.GetProperty(Property.ProductMenu_ID, Locators.Specification.Default);
            driver.Manage().Window.Maximize();
            LoadHtmlFile.CreateTestwrap("New file for check");
            PropertyReader.GetProperty(Property.BASEURL, Locators.Specification.Default);
            driver.FindElement(By.XPath(PropertyReader.GetProperty(Property.Product_Management, Locators.Specification.Default))).Click();
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            Thread.Sleep(1000);
            driver.FindElement(By.Id(PropertyReader.GetProperty(Property.Specifications, Locators.Specification.Default))).Click();
            test.Info("Now i am in the test");
        }
Example #26
0
        public static void FailTestMarkup(String text)
        {
            string  txt   = text;
            IMarkup Amber = MarkupHelper.CreateLabel(text, ExtentColor.Amber);

            scenario.Log(Status.Fail, Amber);

            IMarkup Black = MarkupHelper.CreateLabel(text, ExtentColor.Black);

            scenario.Log(Status.Fail, Black);

            IMarkup Blue = MarkupHelper.CreateLabel(text, ExtentColor.Blue);

            scenario.Log(Status.Fail, Blue);


            IMarkup Brown = MarkupHelper.CreateLabel(text, ExtentColor.Brown);

            scenario.Log(Status.Fail, Brown);


            IMarkup Cyan = MarkupHelper.CreateLabel(text, ExtentColor.Cyan);

            scenario.Log(Status.Fail, Cyan);

            IMarkup Green = MarkupHelper.CreateLabel(text, ExtentColor.Green);

            scenario.Log(Status.Fail, Green);

            IMarkup Grey = MarkupHelper.CreateLabel(text, ExtentColor.Grey);

            scenario.Log(Status.Fail, Grey);

            IMarkup Indigo = MarkupHelper.CreateLabel(text, ExtentColor.Indigo);

            scenario.Log(Status.Fail, Indigo);

            IMarkup Lime = MarkupHelper.CreateLabel(text, ExtentColor.Lime);

            scenario.Log(Status.Fail, Lime);

            IMarkup Orange = MarkupHelper.CreateLabel(text, ExtentColor.Orange);

            scenario.Log(Status.Fail, Orange);
        }
        public void inapplication()
        {
            Console.WriteLine("Time " + String.Format("{0:MM}_{0:D}", DateTime.Now));
            String datetoday = String.Format("{0:D}", DateTime.Now).Replace(",", "_").Replace(" ", "").Replace("Wednesday", "Wed");

            Console.WriteLine(datetoday);
            excelFile.getrowcount("");
            string Spec_CustName = excelFile.GetTestInputValue("SPECIFICATION", "Create_Specification", "Create_RSC_makeBoard", "SPECCUSTNAME");

            excelFile.getrowcount("");
            Console.WriteLine(Spec_CustName.ToLower());
            htmlreporter = new ExtentHtmlReporter("D:\\Nunit_Workspace\\NUnitSamplec\\NUnitSample\\Reports\\" + datetoday + ".html");
            htmlreporter.AppendExisting = true;
            extent = new ExtentReports();
            extent.AttachReporter(htmlreporter);
            Console.WriteLine("Started the test test 1 ");
            extent.AddSystemInfo("Host Name", "Manoj");
            extent.AddSystemInfo("Environment", "QA");
            extent.AddSystemInfo("User Name", "Manoj");
            Console.WriteLine("Started the test test 2 ");
            test  = extent.CreateTest("Create test wrap", "");
            test2 = extent.CreateTest("Second test", "");
            IMarkup m = MarkupHelper.CreateLabel("Create test wrap", ExtentColor.Red);

            test.Log(Status.Warning, "This is the final Log");
            test.Log(Status.Pass, MarkupHelper.CreateLabel("Manoj" + " Test Case PASSED", ExtentColor.Green));
            Console.WriteLine("Output1 : " + Property.ProductMenu_ID);
            driver.Url = PropertyReader.GetProperty(Property.ProductMenu_ID, Locators.Specification.Default);
            driver.Manage().Window.Maximize();
            PropertyReader.GetProperty(Property.BASEURL, Locators.Specification.Default);
            Console.WriteLine("Output : " + PropertyReader.GetProperty(Property.ProductMenu_ID, Locators.Specification.Default));
            extent.AddTestRunnerLogs("Navigated to Gogle ");
            driver.FindElement(By.XPath(PropertyReader.GetProperty(Property.Product_Management, Locators.Specification.Default))).Click();
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            Thread.Sleep(1000);
            // wait.Until(ExpectedConditions.ElementToBeClickable(By.Id(PropertyReader.GetProperty(Property.Specifications, Specification.Default))));
            // var coomon = new Commonfunctions();
            driver.FindElement(By.Id(PropertyReader.GetProperty(Property.Specifications, Locators.Specification.Default))).Click();
            //   coomon.findelement(driver, "id", "Specifications").Click();
            // driver.FindElement(By.Id(PropertyReader.GetProperty(Property.Specifications, Specification.Default))).Click();
            extent.AddTestRunnerLogs("Launched the application");
            test.Info("Now i am in the test");
            extent.Flush();
        }
Example #28
0
 public void SearchUser(IWebElement SearchTextBox, string searchuseremail)
 {
     //DriverUtils.LaunchBrowser("http://cos-test.psr.rd.hpicorp.net/COSWeb/ManageUser/UserManagement");
     SearchTextBox.EnterText(searchuseremail);
     if (!string.IsNullOrEmpty(ManageUsersTableRow.Text) && (!string.IsNullOrWhiteSpace(ManageUsersTableRow.Text) && ManageUsersTableRow.Text.Contains(searchuseremail)))
     {
         Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "Given User\t" + searchuseremail + "\t record exist in the table");
         Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "Given User Details is as follows" + "\t" + ManageUsersTableRow.Text);
         log.Info("Given User\t" + searchuseremail + "\t record exist in the table");
     }
     else
     {
         Console.WriteLine(searchuseremail + "record not found in the table ");
         log.Info(searchuseremail + "\t" + "record not found in the table ");
         string s = BasicMethods.TakeScreenShot();
         Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel("Record not found", ExtentColor.Red)).AddScreenCaptureFromPath(s);
     }
 }
Example #29
0
        //Fucntion to check if checkbox is checked by default
        public static void CheckBox(this IWebElement element)
        {
            bool isChecked = bool.TryParse(element.GetAttribute("checked"), out isChecked);

            if (isChecked)
            {
                Console.WriteLine("This checkbox is already checked!");
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Pass, "This checkbox is already checked!");
            }
            else
            {
                Console.WriteLine("Huh, someone left the checkbox unchecked, lets check it!");
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, "Huh, someone left the checkbox unchecked, lets check it!");
                string s = BasicMethods.TakeScreenShot();
                Common.ExtentReport.test.Log(AventStack.ExtentReports.Status.Fail, MarkupHelper.CreateLabel(" Test case FAILED due to below issue:", ExtentColor.Red)).AddScreenCaptureFromPath(s);
                //element.Click();
            }
        }
Example #30
0
 public void CloseTest()
 {
     test = extent.CreateTest(TestContext.CurrentContext.Test.Name);
     if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed)
     {
         test.Log(Status.Pass, "Test Sucessful");
         test.AddScreenCaptureFromPath(TakeScreenshot.TakeScreenshotMethod(driver, "SearchLocationTestMethod"));
         test.Pass(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Green));
     }
     else if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
     {
         test.Log(Status.Fail, "Test Failed");
         test.AddScreenCaptureFromPath(TakeScreenshot.TakeScreenshotMethod(driver, "SearchLocationTestMethod"));
         test.Pass(MarkupHelper.CreateLabel(TestContext.CurrentContext.Test.Name, ExtentColor.Green));
     }
     // Closes all the connections to the extend reports
     extent.Flush();
 }