Back to Resources

Blog

Posted April 19, 2018

How To Test Offline Modes of Web Applications on Sauce Labs

quote

In today’s world, web applications are the foundation of many enterprise tools and have many states and edge cases that need to be thoroughly tested. While out-of-the-box WebDriver support across various browser vendors is enough to cover most test cases, some areas are still not covered, such as application performance statistics or network manipulation.

As part of a recent announcement, Sauce Labs has released a series of commands that expand on the types of test cases that can be covered while testing on our platforms.

The release includes a tool that exposes Chrome’s native network manipulation features, but in the form of a WebDriver command. Not only does this tool open opportunities to test how the application behaves under various network configurations (e.g 3g or 2g speeds) without the need of a 3rd party proxy, but also how the application would respond when the internet connection is cut off. Additionally, since the feature is implemented on the browser level, Sauce is able to maintain an active WebDriver/VM connection and allow for users to perform assertions on the state of the app.

This is an extremely helpful feature for organizations with applications that have to be used for a long period of time or remain open in the background while the connection can be unstable.

In the example below, we check if the offline mode of an application is working as expected, and if it is able to easily recover when the connection is resumed.

driver.get("https://saucecon.herokuapp.com/"); // Navigating to the page

driver.executeScript('sauce:throttle', { condition: 'offline' })     .then(driver.get("https://saucecon.herokuapp.com/")); // Offline Mode ON

driver.findElement(webdriver.By.css('#info > p:nth-child(1)')).getText()     .then(function (mode) {console.log("Application Status is: " + mode) //Checking the app status});

We’ve also included a number of examples in our public repo (this specific example can be seen by running npm run demo:offline )

Note: this feature is included as part of the Sauce Labs Extended Debugging package. In order to access this functionality, you will need to make sure that you include ‘extendedDebugging’: true in your desired capabilities.

Since the test is executed on the Sauce Labs Continuous Testing Cloud, you will also have access to the video of how the application changes alongside all of the logs, all of which will help you and your teams identify bugs more quickly and deliver quality code at the speed your users demand.

Published:
Apr 19, 2018
Share this post
Copy Share Link
© 2023 Sauce Labs Inc., all rights reserved. SAUCE and SAUCE LABS are registered trademarks owned by Sauce Labs Inc. in the United States, EU, and may be registered in other jurisdictions.