Tosca Integration with Sauce Labs – A 5-Step Guide and Best Practices for Cross-Browser Test Automation

14.6.2023

Tricentis Tosca is a highly versatile test automation tool that can automate a wide variety of applications, including web applications. Tosca uses a browser plugin or extension to execute test cases locally in a browser. This is very advantageous because a test case only needs to be written once, and Tosca can then execute the developed test case on different local browsers using test configuration parameters.

To continue and expand this concept of reusing previously developed test cases across different platforms and browsers, it makes sense to connect a cross-browser cloud provider like Sauce Labs to Tosca for test automation. The advantages of such a solution are:

  • Simple verification of the responsive design of a web application
  • Reduction of effort and costs for maintaining a device infrastructure
  • Expensive acquisition costs for equipment are avoided
  • Achieving higher test coverage

This guide is intended to serve as a manual for integrating Tosca with the Sauce Labs platform, particularly from an enterprise environment with a firewall and web proxy. It also outlines best practices for setting up test cases in Tosca.

Step #1: Hello Sauce Labs – Initial connection setup

To establish a solid foundation for later setup, it's recommended to use a Tosca agent for the initial connection to the Sauce Labs Cloud. This agent should have full access and ideally not be behind a proxy or corporate firewall. While this step may seem trivial, it allows us to revert to this setup at any time during subsequent troubleshooting, enabling us to analyze and potentially isolate connection access errors without limitations.

The goal of the first step looks like this:

We use a simple test case and first ensure that it is executed correctly on the local Tosca agent in the Scratchbook:

Next, the same test case is executed in the Sauce Labs Cloud. We use the EU data center https://ondemand.eu-central-1.saucelabs.com/wd/hub (an overview of all data center endpoints can be found here: Data Center Endpoints | Sauce Labs Documentation).

The test configuration parameter «HubAddress» is to be configured in Tosca according to the following scheme:

By using the parameter "HubAddress", the test case is no longer executed locally, but in the Sauce Labs Cloud. After execution in the Scratchbook, we see the result in the Sauce Labs Cloud. As shown in the image above, specifying the parameter "Browser" is sufficient to run the test. A default value is used for the operating system and browser version.

Next, we will implement execution using Sauce Labs from within the company network using a web proxy.

Step #2: Enterprise Setup – Setting up execution with a proxy connection

To configure Tosca's access to the Sauce Labs Cloud within a corporate network with a proxy server and firewall, additional parameters must be added to the test configuration. However, first and foremost, you should check with your IT department whether the Tosca agents can access the Sauce Labs Cloud. It may be necessary to adjust certain firewall rules.

The setup now looks like this:

Once it is ensured that web access from the Tosca agents to the Sauce Labs data center endpoint is working, three important test configuration parameters need to be added:

  1. WebDriverHubProxyAddress: Address of the proxy server with port
  2. WebDriverProxyUsername: Username for authentication with the web proxy
  3. WebDriverProxyPassword: Password for authentication with the web proxy

Once these parameters have been added to the configuration, we can restart the execution in the Scratchbook and check in Sauce Labs whether the test case was executed correctly. If there are any problems during execution, these should be analyzed in detail with the internal IT department.

During the Sauce Labs test run, you should now take a closer look at the session metadata. If you find that the outdated JWP WebDriver protocol was used, this should definitely be corrected.

Step #3: Using the correct WebDriver protocol (W3C)

The use of the W3C protocol is documented in more detail by Sauce Labs: W3C WebDriver Capabilities Support | Sauce Labs Documentation

Sauce Labs recommends using the newer W3C protocol instead of the JWP (JSON Wire Protocol). The following describes how these recommendations can be implemented with Tosca. The name of the capabilities to be used is crucial.

The Webdriver_platformName configures the platform to be used (the deprecated value "OperatingSystem" must be avoided). Sauce Labs will now use the correct protocol. This can be verified in the "Metadata" tab of the Sauce Labs test environment.

Up to this point, we have successfully established the correct connection between Tosca and Sauce Labs and now have the ability to configure all relevant settings for controlling the test in the cloud. The Sauce Labs Platform Configurator is also very helpful in this regard.

Step #4: Write Once / Use Many – Implementing Cross-Browser Automation of a Tosca Test Case with Sauce Labs

Sauce Labs offers a very helpful tool to generate the configuration parameters of possible device and OS version variants, as well as, for example, screen resolution – the Platform Configurator (Sauce Labs - Platform Configurator):

The setup shown above (Windows 11 / Chrome version 110 / resolution of 1920x1080 pixels) is implemented in Tosca as follows:

Note the correct notation for the different parameters:

  • WebDriver_browserVersion: Here you can enter a version available on Sauce Labs. The value "latest" will use the most recent version.
  • WebDriver_platformName: operating system to be used
  • WebDriver_sauce___screenResolution: The device resolution in Sauce Labs. All Sauce Labs-specific parameters are specified using the scheme «_sauce___optionName» (one underscore «_», followed by «sauce», and then three underscores «_»).

The setup shown above allows a test case, developed once in Tosca, to be run on different platforms in Sauce Labs:

It is recommended to structure the Tosca Execution area with folders according to the required setups and to apply the previously created Tosca test configurations to the corresponding folders:

Within the ExecutionLists, the same test case can now be reused multiple times and thus executed on different setups.

Step #5: Error Analysis and Test Result Reporting

Tosca already offers comprehensive reporting and error analysis capabilities. It is recommended to continue using the existing reporting from test executions in Tosca.

However, Sauce Labs offers further options for traceability of the test procedure. In particular, the video recordings of the test runs provide testers with a comprehensive tool for error analysis:

The commands on the left can also be used to analyze timing problems, for example.

Conclusion

Connecting to Sauce Labs from Tosca is straightforward, even from an enterprise environment with proxy authentication. However, the configuration parameters used are not consistently named, and finding the correct parameters for the connection can sometimes be challenging.

Once the parameters are correctly configured, a comprehensive extension for the Tosca environment is established: Test cases written once can be executed on remote devices. This eliminates the need for the expensive purchase and maintenance-intensive upkeep of the corresponding infrastructure.

Furthermore, Sauce Labs Cloud can be used to automatically test mobile apps on virtual and real devices. This leads to further cost savings and ultimately to higher test coverage.

‍

Training on this topic

Show all
No items found.

We are ready for your next step!

Would you like to utilize our expertise and implement technological innovations?

This website
uses cookies

Cookies are used for user guidance and web analytics and help to improve this website. You can view our cookie policy here or adjust your cookie settings here . By continuing to use this website, you agree to our cookie policy.

All accept
Accept selection
Optimal. Functional cookies to optimize the website, social media cookies, cookies for advertising purposes and the provision of relevant offers on this website and third-party websites, as well as analytical cookies to track website visits.
Limited functionality. Several functional cookies are used for the proper display of the website, e.g., to save your personal settings. No personal data is stored.
Back to overview

Speak to an expert

Do you have a question or are you looking for more information? Provide your contact information and we will call you back.