What is Sauce Labs?

Background

We already talked about Cross Browser Testing and Test Automation in the previous post and we looked at some competitive analysis of the cloud infrastructure services (hardware and platform) that help us. In this post, let’s talk about Sauce Labs.

Agenda

  1. Value Proposition
  2. Manual testing on Sauce labs
  3. Automated testing using saucelabs gem
  4. Execution and results

Value Proposition

If you go to saucelabs home page, this is what we see

saucelabs_homepage

Now, click features and see the highlighted features

saucelabs_features

Manual Testing/ Interactive Session

Let’s first talk about manual testing. Go ahead and sign up using your email as we mentioned before – first play around to get a feel.

Step 1: Dashboard – As soon as you login you will see a dashboard like this

saucelabs_dashboard

Step 2: New interactive session – Click “new interactive session” button or the “arrow with *” on right top corner

  • Enter the URL of the application in the text box provided
  • Choose your resolution
  • Choose your platform – In this case, I chose “windows 7”
  • Choose the browser available on your platform
  • Then click “Test”

saucelabs_interactive_session

Step 3: Allocating cloud machine – This step shouldn’t take long, but for your reference, a fresh cloud instance is being provisioned for you here.

saucelabs_win7_ie11_allocation

Step 4: Interacting with the browser – Once the machine is provisioned, you can interact with the cloud machine through the browser. The orange highlighted are some of the actionable areas on the screen.

saucelabs_interactive_session_interacting

Step 5: Live Share – You can share the current session with someone else and can collaborate on this session.

saucelabs_interactive_session_liveshare

Step 6: Screenshot – You can take a screenshot anytime 

saucelabs_interactive_session_screenshot

Step 7: Copy to – You can copy text to remote clipboard

saucelabs_interactive_session_copyto_remote

Step 8: copy from – you can copy from remote clipboard

saucelabs_interactive_session_copyfrom_remote

Step 9: Raise a bug – You can raise a bug (See the bug icon on the left top corner

Step 10: Stop the session – You can find the stop button (The rectangular box next to play)

Step 11: Back to dashboard – Once you stop the session, you are back to dashboard

saucelabs_interactive_session_dashboard_manual

Post Execution

After you stop the session, you can click the session row and you will be taken to the post execution data. As you can see there is lot of information here highlighted.

saucelabs_interactive_data

Step 1: Screencast – Play the video of whatever you have done on the machine during the session. Just click the play button

 

Step 2: Selenium log – By default a selenium webdriver session is launched. This is NOT so helpful during manual execution, but extremely helpful during automated execution

saucelabs_interactive_data_selenium_log

Step 3: MetaData – This contains all the metadata for this session

saucelabs_interactive_data_selenium_metadata

Step 4: Videos, images – Scroll down meta data section and you will find the videos and screenshots (every action) done in your session. You can download them. By default, saucelabs maintains this for 30 days or something and then automatically purges them

saucelabs_interactive_data_selenium_metadata1

Frankly, that explains pretty much everything you can do with an interactive session on Sauce Labs.

Automated Test Execution

Automated test execution is where this excels. Sauce labs supports any inbound calls that are webdriver compatible (I am not going to go into details of what webdriver is – you should have known by this time if you are reading this. Selenium is a very popular library that follows webdriver protocol and so does appium and many other libraries that are coming these days)

saucelabs gem

There are frankly many ways to do this and this is one of the many ways.saucelabs gem makes life a little easy to communicate with a selenium grid and/or saucelabs. All the documentation for this gem is available – https://github.com/machzqcq/saucelabs

  • Add saucelabs gem in your gem file and bundle install OR gem install saucelabs
  • require ‘saucelabs’ in your environment (env.rb most likely) and then include SauceLabs module
  • Instantiate your browser to use Selenium remote webdriver and point the GRID url to saucelabs provided url (http://<username>:<access_key>@ondemand.saucelabs.com:80/wd/hub) – If you are within a firewall, saucelabs provides a tunnel through which your traffic can securely communicate with sauce network. It is called Sauce Connect. You DO NOT need this if you do not know what it is at this time 🙂 You will automatically know when  you will need this – seriously!
  • A snippet of code looks as below

Let’s write a very simple cucumber scenario and see how saucelabs helps us. Our requirement is very simple – Open a website in various permutations and combinations of web browsers and take the screenshot of landing page

Seleniumframework.feature

Step Definitions

Execution and Results

Once you execute the scenario above, you should have saucelabs.com dashboard open on one of your browsers

  • You will find a row /session automatically created on saucelabs dashboard
  • You can click the session and see the live video executing on it
  • The cucumber session on your machine is sending GET and POST requests (yes webdriver protocol) and the responses of each execution are being recorded into your cucumber results – In this case, we are saving the screenshots for the landing page
  • That is it ! – It is as simple as just changing the way browser gets instantiated by pointing it to saucelabs URL and the magic works 🙂

Video