The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing


External Resources

More Info

Page tree
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
        public void Cleanup()
            // Gets the status of the current test
            bool passed = TestContext.CurrentContext.Result.Outcome.Status == NUnit.Framework.Interfaces.TestStatus.Passed;
                // Logs the result to Sauce Labs
                ((IJavaScriptExecutor)driver).ExecuteScript("sauce:job-result=" + (passed ? "passed" : "failed"));
                // Terminates the remote webdriver session
  • No labels