Katalon Smart Wait: A New Way to Handle Web Loading Issues
Tags: katalon, smartwait, seleniumwaitissue
Published: 2019-12-19 02:56:47

---
title: Katalon Smart Wait: A New Way to Handle Web Loading Issues
published: true
date: 2019-11-15 11:24:06 UTC
tags: katalon,smartwait,selenium wait issue
canonical_url: https://www.katalon.com/resources-center/blog/handle-selenium-wait/
---

![Katalon Smart Wait Selenium Wait](https://d1h3p5fzmizjvp.cloudfront.net/wp-content/uploads/2019/11/15180856/Katalon-Smart-Wait-Selenium-Wait-1024x464.png)

For those who are familiar with Selenium WebDriver, one of the most common features is the Wait command. These commands are handy in test scripts execution, or observing and troubleshooting issues that arise due to time lag.

Wait commands are powerful — but they also come along with a big problem with timing due to front-end processing. Starting from version 7.0.0, we have introduced the **Smart Wait** feature that helps you handle Selenium wait issues without any additional test scripts. 

## **The #1 Selenium’s Villain: Timing Issue**

Most web applications today are developed using front-end technologies such as Javascript or Ajax. With these techniques, after the web page is loaded by the browser, elements on that page might be ready for interacting at unpredictable time intervals. 

This is not an issue to manual testing, but a huge problem to automated testing since no one is there to tell the machine when it should take actions. As a result, you may easily encounter these exceptions while using Selenium: **_NoSuchElementException_, _StaleElementReferenceException_, or _ElementNotVisibleException_.**

There are several solutions to problems in Selenium wait — but they don’t seem to go directly to the point. They were more about mitigating or avoiding the problem than really tackling it. Among these solutions, The Implicit and Explicit wait commands are the most popular solutions.

However, these solutions come with risks and uncertainties. 

- **Implicit wait**  
The implicit wait in Selenium tells the WebDriver to wait for a certain amount of time before sending the **_NoSuchElementException_** exception. This approach is risky since the execution time heavily depends on many external factors. Moreover, there’s no magic formula for the wait time – it’s a case-by-case number. Waiting too long leads to waste, while being too short leads to more likelihood of failure.
- **Explicit wait**  
The explicit wait in Selenium tells the WebDriver to wait for certain conditions or the maximum time exceeded before throwing an **_ElementNotVisibleException_** exception.

This is an intelligent solution as it will wait for dynamically loaded elements. However, it can be only applied for specified elements. Moreover, it will not work in cases where the element is visible but not interactable.

But even if these two solutions work, it requires expertise and manual insertion of wait statements. Furthermore, misunderstanding or not following the best practices of applying implicit and explicit waits could bring up even more problems.

Thus, the solution itself becomes a new timing issue. It leads to many pain points that any automation project may suffer — not only during the test execution phase but also the test design and results analyzing phases: test creation takes more time, code gets worse, execution output becomes unstable, debugging and test maintenance becomes more difficult.

This will eventually lead to poor team performance, costly maintenance expenses and efforts, and low-quality application under test (AUT).

 

## **Katalon Smart Wait Saves the Day**

![Katalon-Smart-Wait](https://d1h3p5fzmizjvp.cloudfront.net/wp-content/uploads/2019/11/15175254/Katalon-Smart-Wait-1024x437.png)

 

This new feature of Katalon Studio cures the pain points mentioned above. 

### **Automatically wait for front-end processes**

Katalon Smart Wait will automatically wait for all front end processes of the web page to complete before taking the next steps; thus completely prevent unstable outputs from happening.

What this means is that all execution results will be consistent. This will save automation engineers a vast amount of time investigating false alarms. Moreover, it would be easier and faster to identify the root causes of issues in case of real failure.

### **Faster execution speed**

Smart Wait can also improve the test execution speed by keeping the results stable — especially in overnight-batch execution, where unexpected failures can stop the whole process, and no one is available to re-run. 

### **Better analytics and insights**

It also keeps the execution history clean and clear for analytics to detect operation insights or patterns. Eventually, team performance will be improved, and better data-driven decisions will be delivered.

**As a result…**

Because timing control codes are no longer needed, the test creation speed would be significantly improved. Teams will have more bandwidth to focus on testing scenarios and improving test scripts quality. 

Moreover, Smart Wait will help reduce the maintenance cost and effort while dealing with the timing codes. Developing and deploying test scripts now becomes less troublesome, even in a highly scalable environment.

 

## **How to Use Katalon Smart Wait**

First, make sure you’ve installed Katalon Studio version 7. **[Download here](https://www.katalon.com/download/)**

There are two ways to apply Smart Wait: to all elements of a project, or to a specific element of a test script.

### **Apply Smart Wait to all elements of a project**

In Katalon Studio, go to:

1. **Projects** > **Settings **
2. On the left sidebar, select **Execution**

On the right sidebar, under **Default Smart Wait** , select **Enable**

![Katalon-Smart-Wait-screenshot](https://d1h3p5fzmizjvp.cloudfront.net/wp-content/uploads/2019/11/15180340/Katalon-Smart-Wait-screenshot-1024x668.png)

### **Apply Smart Wait to a specific element of a script**

To use the Smart Wait function for certain test elements, it’s important that you disable Default Smart Wait in Project Settings:

1. Go to **Projects** > **Settings **
2. On the left sidebar, select **Execution**
3. On the right sidebar, under **Default Smart Wait** , select **Disable**

Use the keywords _enableSmartWait_ and _disableSmartWait_ keywords to enable and disable this function, respectively.

For more details, refer to **[Katalon document](https://docs.katalon.com/katalon-studio/docs/webui-smartwait.html#apply-smart-wait-to-all-elements-in-a-project)**.

To see how Smart Wait works, see **[sample Smart Wait project](https://...)**.

 

### **Conclusion**

Smart Wait is one of our most unique features in the major upgrade of Katalon Studio 7. This feature is a breakthrough solution for Selenium wait issues. It also saves substantial time implementing the waiting script and reducing failed test cases due to the element loading reasons — with no coding required. Plus, this innovation and more to come will help ensure a sustained quality control solution for all automation engineers and teams. 

The post [Katalon Smart Wait: A New Way to Handle Web Loading Issues](https://www.katalon.com/resources-center/blog/handle-selenium-wait/) appeared first on [Katalon Solution](https://www.katalon.com).