Why do we need Saucelabs?
Straight forward answer : Browser Compatibility. We need to test all our testcases in various versions of browsers and various platforms too. We can’t install all those stuff in our local box. Now this Saucelabs plays a major role.

How to integrate your Test scripts with Saucelabs?
It’s quite simple buddies, Just need to follow few stepsStep 1: Sign up for a Sauce Labs account (Free Trail)Step 2: Get your AccessKey from your account (Login and click on ‘My Account‘, Now you will see Access key)Step 3: Choose the Testcases which you want to run on the cloudStep 4: Check your Results (Click on ‘Archives‘ to view the video, Screenshots)

That’s it! All your testcases was executed on different versions and different platforms.You can view the results on clicking ‘Archives‘ in your saucelabs dashboard.

What did I do here? No browser was invoked? Surprised?
Generally we’ll use WebDriver driver = new FirefoxDriver(); command to invoke a browser.
But here we don’t need that, we call RemoteWebDriver class to connect remote driver pointed at ondemand.saucelabs.com specifying your Sauce Labs account credentials and desired browser configuration.

We have DesiredCapabilities to set the configuration.
* browser Represents the browser to be used as part of the test run.
* version Represents the version of the browser to be used as part of the test run.
* os Represents the operating system to be used as part of the test run.
You can also name your job too.

You can also run your tests in parallel using TestNG, JUNIT yada yada. You can also integrate with your CI (Jenkins).This is quite simple and useful right!!