/// <summary> /// Soft assert method to check if the boolean is false /// </summary> /// <param name="condition">Boolean condition</param> /// <param name="softAssertName">Soft assert name</param> /// <param name="failureMessage">Failure message</param> /// <returns>Boolean of the assert</returns> /// <example> /// <code source = "../SeleniumUnitTesting/SeleniumUnitTest.cs" region="SoftAssertIsFalse" lang="C#" /> /// </example> public override bool IsFalse(bool condition, string softAssertName, string failureMessage = "") { bool didPass = base.IsFalse(condition, softAssertName, failureMessage); if (!didPass) { if (Config.GetValue("SoftAssertScreenshot", "No").ToUpper().Equals("YES")) { SeleniumUtilities.CaptureScreenshot(this.webDriver, this.Log, StringProcessor.SafeFormatter(" ({0})", this.NumberOfAsserts)); } return(false); } return(true); }
/// <summary> /// Soft assert method to check if the strings are equal /// </summary> /// <param name="expectedText">Expected text</param> /// <param name="actualText">Actual text</param> /// <param name="softAssertName">Soft assert name to use</param> /// <param name="message">Exception message if desired</param> /// <returns>Boolean if the assert is true</returns> /// <example> /// <code source = "../SeleniumUnitTesting/SeleniumUnitTest.cs" region="SoftAssertAreEqual" lang="C#" /> /// </example> public override bool AreEqual(string expectedText, string actualText, string softAssertName, string message = "") { bool didPass = base.AreEqual(expectedText, actualText, softAssertName, message); if (!didPass) { if (Config.GetValue("SoftAssertScreenshot", "No").ToUpper().Equals("YES")) { SeleniumUtilities.CaptureScreenshot(this.webDriver, this.Log, StringProcessor.SafeFormatter(" ({0})", this.NumberOfAsserts)); } return(false); } return(true); }
/// <summary> /// Take a screen shot if needed and tear down the web driver /// </summary> /// <param name="resultType">The test result</param> protected override void BeforeLoggingTeardown(TestResultType resultType) { // Try to take a screen shot try { if (this.Log is FileLogger && resultType != TestResultType.PASS && this.LoggingEnabledSetting != LoggingEnabled.NO) { SeleniumUtilities.CaptureScreenshot(this.WebDriver, this.Log); } } catch (Exception e) { this.TryToLog(MessageType.WARNING, "Failed to get screen shot because: {0}", e.Message); } this.TryToLog(MessageType.INFORMATION, "Closing webDriver"); try { // Clear the waiter this.WebDriver.RemoveWaitDriver(); // Quite this.WebDriver.Quit(); } catch (Exception e) { this.TryToLog(MessageType.WARNING, "Failed to quit because: {0}", e.Message); } try { this.WebDriver.Dispose(); } catch (Exception e) { this.TryToLog(MessageType.WARNING, "Failed to dispose because: {0}", e.Message); } }