In this post, we will learn how to integrate testing automation to run on saucelabs cloud platform. First ,we will do a quick dive on understanding what is saucelabs, followed by understanding saucelabs platform configurator and then finally walk through a quick video demo along with the sample project on GitHub.
Introduction to Saucelabs
What is Saucelabs
- It is a cloud based automation testing platform that provides thousands of combinations of browsers, platforms, emulators / simulators that are spun up on-demand for web and app automated testing.
- Saucelabs has gained a lot of popularity in recent years, and now has become the industry norm for automated testing. With its ease of use, and a wide variety of options , it is changing the very nature of how automation projects are built and executed.
- Companies that are investing in saucelabs are surely enjoying the best value for their bucks, who would otherwise be spending time, money and effort in maintaining their own test infrastructure. With a free trail-subscription of 14 days, we can instantly spin up any browser / platform combination to get our webpage or app and gather the test stats for free.
Advantages of Saucelabs
Below are some of the advantages it can bring in to any team thats on-boarded to saucelabs:
- Saucelabs is secure ,Seamless and is easy to integrate.
- Every test execution is captured in a video, (besides the logs) that can be referenced later.
- Sauce connect proxy helps to create secure tunnel / proxy connection for testing App / Web page running other locally or with in inside of a corporate network.
- It has excellent support and very well written documentation for preparing capabilities (Platform Configurator) and Cookbook.
- Provides integration support with CI tools such as Jenkins, Bamboo, BitBucket.
Saucelabs platform configurator
Saucelabs platform configurator allows us cherry-pick the browser / device combination along with other attributes and instantly gives us the right config to connect to that device combo. These attributes are otherwise known as selenium capabilities.
The free signup comes with a lot of options to choose for a combination of OS and the browser version for both web and mobile. The list includes Mac (Catalina OS, Mojave, High Sierra and so on) , Windows (Windows 10, windows 8, Windows 7) Linux, free IOS simulators and Android Simulators for supporting IOS13 and Android 9 and lower versions respectively. Visit Saucelabs platform configurator page to know more about it.
Platform configurator supports multi language such as Java, NodeJs, Python, Ruby and C# allowing both legacy projects and recent ones to meet the demand.
Integration of a sample Maven + Java + Selenium Cucumber style project with Saucelabs
- A sample GitHub demo project has been referenced below and is also used in the YouTube video to demo the saucelabs cloud integration.
- After the Capabilities are generated from above step, we plug it into property files (each defining individual capabilities for a given combination) , and use Maven surefire config <SystemPropertyFile> in pom.xml to refer to a given property file name specific to a given device where automation can run.
- Furthermore, Webdriver URL can be constructed using a combination of user id and saucelabs access key that can be generated under user profile. Once an automation run is triggered either via maven build or Junit runner, the maven compiler dynamically loads the corresponding device capabilities and through Hooks file we start connecting to the saucelabs cloud browser.
- With in next few seconds, we see a Handshake session message in the console to confirm that a new instance has spun up on saucelabs cloud and automation has kicked off.
The sample framework (GitHub link) also includes some bonus code to set Unique Build Name & Test Case Name along with property variable <caps> to help easily maintain config changes and promote clean code.
Happy Testing !