Skip to main content

Software Development

Cloud Testing With Selenium – Sauce Labs

2022 10 03 20 53 25 Social Blog What To Expect With Selenium 2.jpg (600×400)

“EXECUTE TEST CASES IN Virtual Machine which are not in your control”

A Cloud Service Provider with one of the biggest grids for running Selenium and Appium test cases is Sauce Labs. Multiple operating systems, browsers, mobile emulators, simulators, and even actual devices are supported by Sauce Labs. According to the Sauce Labs Official Website, they support over 800 Different Operating Systems, Browsers, and Emulator and Simulator Combinations.


If you want to Execute your script on Firefox 24 which is Not Available to you. Yet the client is asking you to execute the selenium test cases in different Browser Combinations and different OS Combinations. In this scenario we do not need to buy this infrastructure. Here the concept Cloud-Based Testing arises. Accessing the servers which have the required infrastructure will help Execute our selenium test cases from our local into those Servers. Organizations have gradually begun to migrate to the cloud to overcome the issue of obtaining physical machines and increasing costs.

In this blog we’ll be focusing on Creating an Account and will Run a Sample Test Case in cloud.


Create an account:

  1. Visit the link Sauce Labs and click on “Try it now”


  1. Sign-up using any of the available methods.

  2. You are all set and ready to run your first test.

We will be using the concept of Digital Capabilities. Desired capabilities class is used when test cases are running on Server or on Virtual Machine outside your local PC scope. When we are using cloud computing, running Appium test cases, we provide the Requirements to the Desired Capability class.

Whenever we start running the Selenium or Appium Test Cases, first it will Read and Understand what capabilities a host is expecting to run.

  1. Which OS?
  2. Which browser?

Then it will go and connect to the source labs, and it will check all the versions and will connect where the requirements are Satisfied.


  1. Run a Sample Test Case.


public static final String USERNAME = "JohnDoe";
public static final String ACCESS_KEY = "xxxxx";
public static final String URL = "http://" + USERNAME + ":" + ACCESS_KEY + "";

 We are defining a string “URL”. It is for the connection establishment with Sauce Labs

Here the username will be the one you specified. To generate the access key, please follow the steps:

  1. Click on Account Icon
  2. Click on “User Setting”
  3. You can find the access key here.

Next, we need to send the Desired Capabilities with the desired requirement.


        DesiredCapabilities caps =;

        caps.setCapability("platform", "Windows 7");

        caps.setCapability("version", "47.0");

In this scenario “caps” are the Desired Capabilities which we are Sending to the sauce labs. In response we will get a RemoteWebDriver which will be used to carry out our testing.


public class SauceLabDemo{

public static final String USERNAME = "JohnDoe";

public static final String ACCESS_KEY = "xxxxx";

public static final String URL = "http://" + USERNAME + ":" + ACCESS_KEY + "";

public static void main(String[] args) throws MalformedURLException {
        DesiredCapabilities caps =;

        caps.setCapability("platform", "Windows 7");

        caps.setCapability("version", "47.0");

        WebDriver driver=new RemoteWebDriver(new URL(URL), caps);





To avoid any confusion and error while specifying the desired capabilities, SauceLabs came up with one Tool called Platform Configurator which Generates The Code for desired capabilities based on our preferences.

By opening the link and providing all your capabilities, it will generate the code for you.

After running your test, you can also Monitor Your Test Result.


  1. Go to the Sauce Labs
  2. Click on “Dashboard”
  3. Click on “Automatic Test”
  4. You can verify that the test is present

To know more about “Selenium With Sauce Labs” you can visit the link.

Congratulations Gif - GIFcen

Conclusion: Congratulations, You have successfully Created your SauceLabs Account and also Configured your selenium with it. In addition, you have also Tested the report through the dashboard.

Happy Coding

Happy Coding!

Thoughts on “Cloud Testing With Selenium – Sauce Labs”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Sanket Dudhe

Sanket Dudhe is an Associate Technical Consultant at Perficient. He has an experience of 4+ years as SDET. He loves technology and hence is curious to learn about new emerging technologies #lovefortechnology.

More from this Author

Follow Us