public void InsertReportingSteps(ScenarioContext scenarioContext) { //OK = 0, //StepDefinitionPending = 1, //UndefinedStep = 2, //BindingError = 3, //TestError = 4, //Skipped = 5 //ScenarioExecutionStatus stepStatus = scenarioContext.ScenarioExecutionStatus; //public enum Status //{ // Pass = 0, // Fail = 1, // Fatal = 2, // Error = 3, // Warning = 4, // Info = 5, // Skip = 6, // Debug = 7 //} if (scenarioContext.TestError != null) { ExtentTestManager.GetMethod() .Fail(scenarioContext.TestError.Message) .Log(Status.Error, scenarioContext.TestError.Message); } }
public static void RunBeforeAll() { var prefix = "RUN" + DateTime.Now.ToString("ddMMMyyyyhhmm").ToUpper(); var saveDirectoryRoot = $"{TestSettings.ReportFolder}\\TestResults\\{prefix}"; ExtentTestManager.InitializeTestSuiteReporting(saveDirectoryRoot, "INSIGHT AUTOMATION"); }
public void SetUp() { Config.SetUIEnvVariables(); //Create extent test extentTest = ExtentTestManager.StartTest(TestContextInfo.TestName, TestContextInfo.Description, TestContextInfo.Categories); Log = new Logger(Utils.GetLogFile(TestContextInfo.CurrentContext), TestContextInfo.CurrentContext, extentTest); Log.StartTest(); // Delete old log files FileUtils.DeleteFilesOlderThan(Constants.LogRetentionDays, Utils.GetLogFolder(), Constants.LogExtension); FileUtils.DeleteFilesOlderThan(Constants.LogRetentionDays, Utils.GetScreenshotFolder(), Constants.ImgExtension); //Create new web driver DriverUtils.CreateDriver(new DriverProperties(Config.ConfigFilePath, Config.Driver)); DriverUtils.Maximize(); DriverUtils.GoToUrl(Config.Url); //Initial page objects PageFactory.InitialPageObjects(this); }
public void AfterTest() { string screenShotPath = BaseTest.Capture(TestContext.CurrentContext.Test.Name); var status = TestContext.CurrentContext.Result.Outcome.Status; var stacktrace = string.IsNullOrEmpty(TestContext.CurrentContext.Result.StackTrace) ? "" : string.Format("<pre>{0}</pre>", TestContext.CurrentContext.Result.StackTrace); Status logstatus; switch (status) { case TestStatus.Failed: logstatus = Status.Fail; break; case TestStatus.Inconclusive: logstatus = Status.Warning; break; case TestStatus.Skipped: logstatus = Status.Skip; break; default: logstatus = Status.Pass; break; } ExtentTestManager.GetTest().Log(logstatus, "Test ended with " + logstatus + stacktrace); ExtentTestManager.GetTest().Log(logstatus, "Snapshot below: " + ExtentTestManager.GetTest().AddScreenCaptureFromPath(screenShotPath)); }
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(); }
public DataTable CloseDB() { DB.DbClose(Conn); ExtentTestManager.GetTest().Log(Status.Info, "DB Connection Closed"); return(Result); }
protected DataSetUpContext _setUpContext; // fixture level parallelization public BaseSetUp() { // force children/subclasses to have a constructor for creating extent report test instance // currenly ClassName prints namespace + test clsasname parentTest = ExtentTestManager.CreateTest(CurrentContext.Test.ClassName); _setUpContext = new DataSetUpContext(); }
public IWebDriver OpenBrowser() { IWebDriver driver = null; var runTests = TestSettings[TestSettingsConst.RUN_TEST]; if (string.Equals(runTests, RunTest.Sauce.ToString(), StringComparison.CurrentCultureIgnoreCase)) { var caps = new DesiredCapabilities(); var browser = TestSettings[TestSettingsConst.BROWSER]; //"chrome"; var version = TestSettings[TestSettingsConst.VERSION]; //"45"; var os = TestSettings[TestSettingsConst.OS]; //"Windows 7"; var deviceName = TestSettings[TestSettingsConst.DEVICENAME]; //""; var deviceOrientation = TestSettings[TestSettingsConst.DEVICEORIENTATION]; //""; caps.SetCapability(CapabilityType.BrowserName, browser); caps.SetCapability(CapabilityType.Version, version); caps.SetCapability(CapabilityType.Platform, os); caps.SetCapability("deviceName", deviceName); caps.SetCapability("deviceOrientation", deviceOrientation); caps.SetCapability("username", TestSettings[TestSettingsConst.USERNAME_SAUCE]); caps.SetCapability("accessKey", TestSettings[TestSettingsConst.ACCESS_KEY_SAUCE]); caps.SetCapability("name", TestContext.CurrentContext.Test.Name); driver = new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com:80/wd/hub"), caps, TimeSpan.FromSeconds(600)); } else { //if (string.Equals(runTests, RunTest.Local.ToString(), StringComparison.CurrentCultureIgnoreCase)) { var br = new Browser(); driver = br.InitializeBrowser(TestSettings); driver.Manage().Window.Maximize(); ExtentTestManager.GetTest().Log(Status.Info, "Opened Browser" + TestSettings[TestSettingsConst.BROWSER]); } return(driver); }
public void AfterTest() { var status = TestContext.CurrentContext.Result.Outcome.Status; var stacktrace = string.IsNullOrEmpty(TestContext.CurrentContext.Result.Message) ? "" : string.Format("<pre>{0}</pre>", TestContext.CurrentContext.Result.Message); Status logstatus; switch (status) { case TestStatus.Failed: logstatus = Status.Fail; break; case TestStatus.Inconclusive: logstatus = Status.Warning; break; case TestStatus.Skipped: logstatus = Status.Skip; break; default: logstatus = Status.Pass; break; } ExtentTestManager.GetTest().Log(logstatus, "Test ended with " + logstatus + stacktrace); }
public bool DoesAllButtonsContainAddToCartText() { ExtentTestManager.GetTest().CreateStep(MethodBase.GetCurrentMethod().Name); return(_addToCartButtons.GetElements() .Select(x => x.Text) .All(x => x.Equals(Constants.AddToCart))); }
public void TestSetup() { // extent reports setup _test = ExtentTestManager.StartTest(TestContext.Properties["TestCaseName"].ToString(), TestContext.Properties["TestCaseDescription"].ToString()) .AssignCategory("Smoke"); }
public void TC_VerifyMaintainWeightGoal() { Page_Login plogin = new Page_Login(); plogin.Login(); ExtentTestManager.GetTest().Info("Successfully Logged In"); Page_HAPrompt haprompt = new Page_HAPrompt(); haprompt.GoToDashboard(); Common cmn = new Common(); cmn.ClickGoalMenu(); Page_MaintainWeightGoal mwgoal = new Page_MaintainWeightGoal(); List <string[]> result = mwgoal.ValidateElements(); Assert.Multiple(() => { for (int i = 0; i < result.Count; i++) { bool textmatchresult = Convert.ToBoolean(result.ElementAt(i)[1]); string msg = result.ElementAt(i)[0]; Assert.IsTrue(textmatchresult, msg); } } ); }
public void TearDown() { if (!_testFinished) { try { var status = TestContext.CurrentContext.Result.Outcome.Status; var stacktrace = string.IsNullOrEmpty(TestContext.CurrentContext.Result.StackTrace) ? "" : string.Format("<pre>{0}</pre>", TestContext.CurrentContext.Result.StackTrace); Status logstatus; switch (status) { case TestStatus.Failed: logstatus = Status.Fail; break; case TestStatus.Inconclusive: logstatus = Status.Warning; break; case TestStatus.Skipped: logstatus = Status.Skip; break; default: logstatus = Status.Pass; break; } ExtentTestManager.GetTest().Log(logstatus, "Test ended with status: " + logstatus + stacktrace); } catch { } } }
public void Setup() { //SubTest = Test.CreateNode(TestContext.CurrentContext.Test.FullName); //Setup(SubTest, path); SubTest = ExtentTestManager.CreateTest(TestContext.CurrentContext.Test.Name); Setup(SubTest, path); _testFinished = false; }
public static void BeforeFeature(FeatureContext featureContext) { var featureName = featureContext.FeatureInfo.Title; _feature = ExtentTestManager.CreateTest(new GherkinKeyword("Feature"), featureName); //name of feature file TryLoadingWorkSheetWithFeatureName(featureName); // initialise driver here instead of beforescenario hook? }
public TestFixture() { Driver = WebDriverFactory.Driver; Utils = new Utilities(); Driver.Navigate().GoToUrl(Utils.Url); Driver.Manage().Window.Maximize(); CurrentPath = Directory.GetCurrentDirectory(); Extent = ExtentTestManager.ExtentReportInstance(); }
public void DbClose(SqlConnection sqlConnection) { try { sqlConnection.Close(); } catch (Exception e) { ExtentTestManager.GetTest().Log(Status.Info, "Error :: " + e.Message); } }
public void TestSetup() { // extent reports setup test = ExtentTestManager.StartTest(TestContext.Properties["TestCaseName"].ToString(), TestContext.Properties["TestCaseDescription"].ToString()) .AssignCategory("Smoke"); // No selenium needed for this at the moment... }
public void PerformLogin(string username) { _loginButton.WaitUntilElementIsVisible(); _userNameInput.ActionSendKeys(username); _passwordInput.ActionSendKeys(Constants.Password); _loginButton.Submit(); ExtentTestManager.GetTest() .CreateStep(MethodBase.GetCurrentMethod().Name, $"Logged in with {username}"); }
public void AreEqual(string expected, string actual, string customMessage) { try { Assert.AreEqual(expected.ToLower(), actual.ToLower()); ExtentTestManager.GetTest().Log(Status.Info, customMessage + " Validation Passed\"" + "\", Expetcted(Test Data Source) : \"" + expected + "\"" + "Actual : \"" + actual + "\""); } catch (Exception e) { ExtentTestManager.GetTest().Log(Status.Error, "Assertion Failed,\"" + customMessage + "\", Expected(Test Data Source) : \"" + expected + " \"" + "Actual : " + actual + e.Message); } }
public void That(IWebElement element, string message) { try { Assert.That(element.Displayed); ExtentTestManager.GetTest().Log(Status.Pass, message + "is Displayed"); } catch (Exception) { ExtentTestManager.GetTest().Log(Status.Error, message + "not is Displayed"); } }
public void OneTimeSetupTestSuite() { var configsSuite = new ConfigsBeforeEachTestSuite(); var AssemblyDirectory = Assembly.Directory; TestSettings = configsSuite.TestSetup(AssemblyDirectory + ResourceConstants.SETTINGSPATH + "/TestSettings.json"); Environment = configsSuite.ReadEnvironmentFromJson(Assembly.Directory + ResourceConstants.SETTINGSPATH + "/Environment.json", TestSettings[TestSettingsConst.ENVIRONMENT]); ExtentTestManager.CreateParentTest(GetType().Name); }
public void Click(IWebElement element, string name) { try { element.Click(); ExtentTestManager.GetTest().Log(Status.Info, "Clicked the \"" + name + " \""); } catch (Exception e) { ExtentTestManager.GetTest().Log(Status.Error, "Exception in Click element \"" + name + " \"" + e.Message); } }
public virtual void StartDriver() { TestAdapter currentTest = CurrentContext.Test; childTest = ExtentTestManager.CreateMethod(parentTest.Model.Name, $"{currentTest.Name}"); DriverManager.StartDriver(TestConfig.Browser); Driver = DriverManager.GetDriver(); HomePage homePage = new HomePage(Driver); homePage.Open(); }
private void ExtractTestContextData() { Type type = _testcontext.GetType(); FieldInfo method = type.GetField("test", BindingFlags.Instance | BindingFlags.NonPublic); ITest test = (ITest)method.GetValue(_testcontext); TestMethodName = test.DisplayName; TestClassName = TypeDescriptor.GetClassName(this); parentTest = ExtentTestManager.CreateTest(TestClassName, test.TestCase.Traits["Description"].First()); testReporter = ExtentTestManager.CreateMethod(TestMethodName); }
public void verifyQuantityafterDelete() { if ((TotalProduct.Text).Contains("1")) { ExtentTestManager.GetTest().Log(Status.Pass, "Second Product is deleted successfully"); } else { ExtentTestManager.GetTest().Log(Status.Fail, "Deletion operation is not performed"); } }
public void finalverifyQuantity() { if ((AddedProduct.Text).Contains("2")) { ExtentTestManager.GetTest().Log(Status.Pass, "Two products are added to cart"); } else { ExtentTestManager.GetTest().Log(Status.Fail, "Cart is empty; need to add again"); } }
public void verifyLogin() { if (BaseTest.WaitUntilElementExists(loggedon)) { ExtentTestManager.GetTest().Log(Status.Pass, "User Logged On"); } else { ExtentTestManager.GetTest().Log(Status.Fail, "User is not Logged On"); } }
public void validateLaunch() { if (BaseTest.WaitUntilElementExists(login)) { ExtentTestManager.GetTest().Log(Status.Pass, "Application Launched properly"); } else { ExtentTestManager.GetTest().Log(Status.Fail, "Application is not Launched properly"); } }
public void TestSetup() { // extent reports setup test = ExtentTestManager.StartTest(TestContext.Properties["TestCaseName"].ToString(), TestContext.Properties["TestCaseDescription"].ToString()) .AssignCategory("Smoke"); // browser setup _driver = SetUp(_BT); _driver.Manage().Window.Maximize(); }