Example #1
0
        /// <summary>
        /// Transforms a markdown file into valid HTML and create a HTML file into the local folder in ApplicationData.
        /// </summary>
        /// <param name="markdownFilePath"> The path of the markdown file.</param>
        public void TransformToHtml(string markdownFilePath)
        {
            if (!File.Exists(markdownFilePath))
            {
                throw new FileNotFoundException(string.Format("Could not find the file at the path : '{0}'", markdownFilePath));
            }

            if (!Directory.Exists(PathDocuPanelAppData))
            {
                Directory.CreateDirectory(PathDocuPanelAppData);
            }

            // Initalize the MarkdownDeep object.
            var md = new Markdown
            {
                ExtraMode      = true,
                SafeMode       = true,
                AutoHeadingIDs = true
            };

            // Read the markdown file and transform the content into HTML.
            var content     = File.ReadAllText(markdownFilePath);
            var transformed = md.Transform(content);
            var wrapped     = MarkupHelper.WrapHtmlBody(transformed);

            // Create or override a HTML file.
            var htmlFilePath = this.ConvertMarkdownFilePathToHtmlFilePath(markdownFilePath);

            File.WriteAllText(htmlFilePath, wrapped);
        }
        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();
        }
 public void ERROR(string content)
 {
     if (getreport)
     {
         _extentTObj.Error(MarkupHelper.CreateLabel(content, ExtentColor.Red));
     }
 }
 public void WARNING(string content)
 {
     if (getreport)
     {
         _extentTObj.Warning(MarkupHelper.CreateLabel(content, ExtentColor.Orange));
     }
 }
 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 #7
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 #8
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 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 #10
0
        public static ExtentTest CreateTestwrap(string description)
        {
            test = extent.CreateTest(description, "");
            IMarkup m = MarkupHelper.CreateLabel(description, ExtentColor.Red);

            return(test);
        }
        protected void NoCodeFixAtLine(string code, string diagnosticId, int line)
        {
            var document = MarkupHelper.GetDocumentFromMarkup(code, LanguageName, References);
            var locator  = LineLocator.FromCode(code, line);

            NoCodeFix(document, diagnosticId, locator);
        }
Example #12
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);
            }
        }
        protected void TestCodeRefactoringAtLine(string code, string expected, int line, int refactoringIndex = 0)
        {
            var document = MarkupHelper.GetDocumentFromCode(code, LanguageName, References);
            var locator  = LineLocator.FromCode(code, line);

            TestCodeRefactoring(document, expected, locator, refactoringIndex);
        }
        protected void TestCodeFix(string markupCode, string expected, string diagnosticId, int codeFixIndex = 0)
        {
            var document = MarkupHelper.GetDocumentFromMarkup(markupCode, LanguageName, References);
            var locator  = MarkupHelper.GetLocator(markupCode);

            TestCodeFix(document, expected, diagnosticId, locator, codeFixIndex);
        }
        protected void TestCodeRefactoring(string markupCode, string expected, int refactoringIndex = 0)
        {
            var document = MarkupHelper.GetDocumentFromMarkup(markupCode, LanguageName, References);
            var locator  = MarkupHelper.GetLocator(markupCode);

            TestCodeRefactoring(document, expected, locator, refactoringIndex);
        }
        protected void TestCodeFixAtLine(string code, string expected, string diagnosticId, int line, int codeFixIndex = 0)
        {
            var document = MarkupHelper.GetDocumentFromMarkup(code, LanguageName, References);
            var locator  = LineLocator.FromCode(code, line);

            TestCodeFix(document, expected, diagnosticId, locator, codeFixIndex);
        }
Example #17
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);
     }
 }
        protected void NoCodeFix(string markupCode, string diagnosticId)
        {
            var document = MarkupHelper.GetDocumentFromMarkup(markupCode, LanguageName, References);
            var locator  = MarkupHelper.GetLocator(markupCode);

            NoCodeFix(document, diagnosticId, locator);
        }
        protected void HasDiagnosticAtLine(string code, string diagnosticId, int lineNumber)
        {
            var document = MarkupHelper.GetDocumentFromCode(code, LanguageName, References);
            var locator  = LineLocator.FromCode(code, lineNumber);

            HasDiagnostic(document, diagnosticId, locator);
        }
Example #20
0
        public void TearDown()
        {
            try
            {
                if (TestContextInfo.Result.Outcome.Status != TestStatus.Passed)
                {
                    var screenshotPath = Utils.GeScreenshotFile(TestContextInfo.CurrentContext);
                    DriverUtils.TakeScreenshot(screenshotPath);
                    AddTestAttachment(screenshotPath);
                    Log.GetBrowserLog();

                    //Add screenshot for extents report
                    extentTest.Fail(MarkupHelper.CreateCodeBlock(TestContextInfo.Result.Message));
                    extentTest.AddScreenCaptureFromPath(screenshotPath);
                }

                AddTestAttachment(Log.LogPath);
                ExtentTestManager.EndTest();
                DriverUtils.CloseDrivers();
            }
            catch (Exception e)
            {
                Log.Error(e);
                extentTest.Error(e);
            }

            Log.EndTest();
        }
Example #21
0
        protected void TestCompletion(string markupCode, Action <ImmutableArray <CompletionItem> > assertion, CompletionTrigger?trigger = null)
        {
            var document = MarkupHelper.GetDocumentFromMarkup(markupCode, LanguageName, References);
            var locator  = MarkupHelper.GetLocator(markupCode);

            VerifyExpectations(document, locator, trigger, assertion);
        }
        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 #23
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();
        }
        protected void TestNoCodeRefactoring(string markupCode)
        {
            var document = MarkupHelper.GetDocumentFromMarkup(markupCode, LanguageName, References);
            var locator  = MarkupHelper.GetLocator(markupCode);

            TestNoCodeRefactoring(document, locator);
        }
        protected void TestCodeFix(string markupCode, string expected, DiagnosticDescriptor descriptor, int codeFixIndex = 0)
        {
            var document   = MarkupHelper.GetDocumentFromMarkup(markupCode, LanguageName, References);
            var locator    = MarkupHelper.GetLocator(markupCode);
            var diagnostic = FindOrCreateDiagnosticForDescriptor(document, descriptor, locator);

            TestCodeFix(document, expected, diagnostic, locator, codeFixIndex);
        }
        protected void NoCodeFix(string markupCode, DiagnosticDescriptor descriptor)
        {
            var document   = MarkupHelper.GetDocumentFromMarkup(markupCode, LanguageName, References);
            var locator    = MarkupHelper.GetLocator(markupCode);
            var diagnostic = FindOrCreateDiagnosticForDescriptor(document, descriptor, locator);

            NoCodeFix(document, diagnostic, locator);
        }
Example #27
0
        protected void TestCompletion(string markupCode, string[] expectedCompletions, CompletionTrigger?trigger = null)
        {
            var document  = MarkupHelper.GetDocumentFromMarkup(markupCode, LanguageName, References);
            var locator   = MarkupHelper.GetLocator(markupCode);
            var assertion = CreateAssertionBasedOnExpectedSet(expectedCompletions, locator);

            VerifyExpectations(document, locator, trigger, assertion);
        }
        protected void NoCodeFixAtLine(string code, DiagnosticDescriptor descriptor, int line)
        {
            var document   = MarkupHelper.GetDocumentFromMarkup(code, LanguageName, References);
            var locator    = LineLocator.FromCode(code, line);
            var diagnostic = FindOrCreateDiagnosticForDescriptor(document, descriptor, locator);

            NoCodeFix(document, diagnostic, locator);
        }
Example #29
0
        public static void InfoTestMarkup(string text)
        {
            String code = " \n\t \n\t\t" + text + "\n\t \n ";

            IMarkup p = MarkupHelper.CreateCodeBlock(code);

            scenario.Log(Status.Info, p);
        }
        public static void markupCodeblock(string text, Status status)
        {
            String  code = "\n\t\n\t\t" + text + "\n\t\n";
            IMarkup m    = MarkupHelper.CreateCodeBlock(code);


            test.Log(status, m);
        }