Skip to end of metadata
Go to start of metadata

Selenium is a protocol focused on automating the actions of a browser, and as such, it doesn't encompass the notions of a "test" that "passes" or "fails." Because of this, you need to include a section in your code that explicitly gets the status of the test, and then sends it to the Sauce Labs dashboard. 

C# Code for Reporting Test Results to the Sauce Labs Dashboard
 [TearDown]
        public void Cleanup()
        {
            // Gets the status of the current test
            bool passed = TestContext.CurrentContext.Result.Outcome.Status == NUnit.Framework.Interfaces.TestStatus.Passed;
            try
            {
                // Logs the result to Sauce Labs
                ((IJavaScriptExecutor)driver).ExecuteScript("sauce:job-result=" + (passed ? "passed" : "failed"));
            }
            finally
            {
                // Terminates the remote webdriver session
                driver.Quit();
            }
            
        } 
  • No labels