Cross-browser Testing using Sauce Labs

Cross-browser Testing using Sauce Labs

Overview

A web application can be opened in different devices, browsers, operating systems, and so on by an end user. Cross-browser testing or browser compatibility testing is needed to ensure that the application works as expected in all browsers. This includes testing in both client and server sides.

It is highly painful to manually perform the cross-browser testing. To minimize testing efforts, multiple automation tools can be used to perform the browser compatibility testing.

The metrics to be considered while performing the cross-browser testing are:

  • Code Validation – Validate JavaScript and CSS across different browsers and versions
  • Application Performance – Get optimal response on all platforms
  • Device Support – Support mobile devices such as mobile and tablet based on resolution, rotation, and viewport
  • Base Functionality – User experience should be the same throughout, navigation, links, and dialog boxes

In this blog post, we will discuss about installing Sauce Labs and performing cross-browser testing using Sauce Labs.

Why Sauce Labs for Cross-browser Testing?

Sauce Labs, a very popular cross-browser testing tool among developers, features Selenium testing, mobile testing, and JS unit testing. It can be used to perform automated mobile and web testing in parallel. It does not require any Virtual Machine (VM) setup.

Sauce Labs Features

  • Offers both automated testing and manual testing features to test web applications.
  • Supports around 1500+ versions of desktop and mobile browsers such as Internet Explorer, Chrome, Opera, Safari, and Firefox.
  • Supports Operating Systems such as Windows, Linux, Android, and IOS.

Pre-requisites

  • Install Selenium WebDriver (v2.47.0 or lower)
  • Install Node.js (v.0.11 or higher)
  • Get Sauce Labs Access Key by performing the following steps:
    • Login to Sauce Labs with valid username and password.
    • Go to My Account and click Show button.
    • Enter the password of sauce account to see/copy the sauce access key.
    • Use the access key in the configuration file to run the scripts in cloud.
  • Install Sauce Labs using the below command:
    After installation, Sauce Labs version will be automatically updated in package.json file.
    Latest version: “saucelabs”: “^1.3.0″

Cross-browser Testing using Sauce Labs

Sauce Labs Configuration Setup in Nightwatch

  1. Go to Nightwatch.js file in the Nightwatch directory.
  2. Declare the Sauce Labs credentials.
  3. Setup the Selenium webdriver.
  4. Perform setup to run scripts in Sauce Labs by default.

Credentials to access the Sauce labs
“username”: sauce_username
“access_key”: sauce_accessKey

Running Scripts in Sauce Labs

Running script in a default browser

Running a script in Sauce Labs will automatically run the same script in Linux OS along with the latest version of Chrome browser.

Running script in a specified OS or specified version of the browser

Configuration for Desktop Firefox Browser

Configuration for Mobile Device

select

Running pre-written test script in Sauce Labs

  • To launch test scripts in Sauce Labs default browser (Chrome), use the below command:
  • To launch test scripts in Sauce Labs with a particular browser, use the below command:
  • To launch test scripts in Sauce Labs with all browsers and local system browser, use the below command:

select

Checking Logs in Sauce Labs

To check the logs in Sauce Labs, perform the following:

  • Log in to Sauce Labs page with your username and password to check detailed reports.
  • In Sauce Labs dashboard, view all the running scripts and manual scripts as shown in the below diagram:

select

Generating Reports

The sample report generated for the default browser–Chrome is shown in HTML format in the below diagram:

select

References

Test Configuration Options:
https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options

1950 Views 6 Views Today