Please post your Web Driver questions in official Web Driver forum

Tuesday, January 3, 2012

Updating Sauce Labs dashboard with Selenium 2 test results

If you have not yet known of Sauce Labs, Sauce Labs specialises in executing Selenium tests on cloud. If you don't want to manage those umpteen configurations for executing your Selenium tests, then Sauce Labs is the answer. I am not going to explain executing your Selenium tests on Sauce Labs as there is enough documentation on Sauce Labs which already explains this. What I was stuck with is updating test results on Sauce Labs dashboard. Status "finished" does not indicate about success/failure of tests and you may probably not have time to see log/video of each and every finished tests.

I posted query to Sauce Labs and got to know about the Sauce Labs REST api. But things were still not very clear as I was not sure of on what basis I could update test results in Sauce Labs dashboard.
How do I get to know from a tests whether it succeeded or not and then update the Sauce Labs dashboard. This is when TestNG came to my rescue. TestNG ITestResult could be injected in tear down method to find the status of test execution and on the basis of this Sauce Labs dashboard could be set with pass or fail status.

I also found it useful to update the job name with name of test method to make Sauce Labs dashboard results more comprehensible. This is how my tear down method looks -

And here is the Sauce Labs dashboard with test status -

Fork me on GitHub