Cloud Testing with Selenium – Sauce Labs

Introduction to cloud testing

     Basically we can execute the automation test scripts in the VMs, which are not in our control. Example, if we want to execute the script on Firefox version 24.0 which is not available for us. So the infrastructures which are the company provided for us are limited; client asks to execute the scripts in different browser configuration and different OS configuration. Cloud testing is on-demand one. In the tight schedule of test execution we can’t buy all the infrastructures. So for that the concept came up is the cloud based testing. In the case of Level 3 companies; most of the cases they go to test in cloud. Through this we can run our script local into those servers in the cloud.

     Here I would like to introduce a cloud testing concept called Sauce Lab. Sauce Lab is the cloud testing component. This is basically designed for automation testing as well as manual testing. We can execute the test cases in Sauce cloud. Following are the important concepts related to automation testing in sauce lab cloud:

Sauce Lab account creation

     The Sauce Lab infrastructure is paid one. We can also create the free accounts for 14-days. Your 14 days won’t begin until you run your first test. It is providing 8 concurrent VMs, 90 Hours of automation testing and unlimited manual testing. No credit card needed to create a free account. Needed following information to create a free account in Sauce Lab: First Name, Last Name, Email, Company name, Company Size, Username and Password.

     Once you done the registration it will take you to “Run your first test now!” window with following options:

1. Automated – Run your automation Selenium test or JavaScript unit tests.

2. Mobile – Automatically test your hybrid and native iOS and Android apps.

3. Manual – Test your site in any browser instantly, like IE 7 or mobile safari.

     We can select any of the above options based on your requirements of testing. If we move to dashboard in the Sauce Lab; we can see the jobs and its details (is it running/completed).

Test script execution in cloud

     Before moving to scripting, I would like to share something about Desired Capabilities class. This class is basically use when you are running the test cases on a server or somewhere VMs outside of local PC scope or when we use the cloud computing as well as run the appium test cases. We will provide our entire requirement to Desired Capabilities class. Example: I need to run on Mac machine or run on Windows. Also I need to run on Firefox xx version. These as the desired capability and need to pass these requirements to this class. When we start the automation the object first read and understands that what are the capabilities the host is expecting to run the test cases.  What OS it wants to run and what browser it is expecting? Then it will go and connect to the Sauce Lab and it checks all the VMs and where ever the requirement is satisfied. In Sauce Lab there are 100 VMs are available. Once we send these requirements with help of Desired Capabilities class to cloud and the response will come from cloud, then after our test script will execute in the cloud.

     To run the test script on the cloud we needs the test script in local; make sure that we have added all the mandatory annotations in the script (say @BeforeTest, @Test and @AfterTest). Another important aspect is Desired Capabilities; based on the test execution requirement we can add the capabilities and send them to the server for execution. I have mentioned the following are desired capabilities that I added for my test execution requirement:

cloud testing

     Apart from normal selenium script, the major change will happen in the section of WebDriver initialization. In URL, there are two parameters: one is where we want to run the test cases and second, what are capabilities need to send to the server through the specified URL. The syntax of first parameter is below:

     http://saucelabid:Accesskey@ondemand.saucelabs.com:80/wd/hub

     Once we set all ready and next step is to run the script as normal way. When the script starts run just go back to your Sauce Lab dashboard, there you can see the job sessions and same time you see test execution environment, results of test execution, run time etc., Tap on “View Fullscreen” link, we will get the complete test execution status. It includes Screencast section that explains the current test execution as live video; we can track the selenium logs, Commands, metadata. Below are the screens of Sauce Lab dashboard and test execution full view:

1

Figure 1: Dashboard view with jobs in beta version

2

Figure 2: Dashboard view with jobs in non-beta version

3

Figure 3: Command view

4

Figure 4: Screencast view

5

Figure 5: Selenium Logs

6

Figure 6: Metadata view

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s