[WebUI] Smart Wait Function
- The Smart Wait function is available on Chrome, Edge Chromium (from version 8.2.0 onwards), and Firefox.
From version 9.0.0.alpha1, Smart Wait becomes the built-in function of Katalon Studio and also applies for remote execution. You can download version 9.0.0.alpha1 from our GitHub repository: Katalon Studio version 9.0.0.alpha1.
Description
One of the most common problems is that Katalon users cannot interact with web page elements, which causes automation tests to fail. Some elements are neither visible nor interactable, the other would receive the operations instead of the intended ones. This issue is because the page hasn't fully loaded or some operations (adding, removing, or modifying elements) haven't finished performing yet.
From Katalon Studio version 7.0.0 onwards, you can enable Smart Wait in Project Settings to tell the web driver to wait for the web page to become static before performing any operations.
You can download the Smart Wait sample project from our GitHub repository: Smart Wait sample tests.
Requirements
Katalon Studio version 7.0.0 onwards.
Apply Smart Wait for WebUI testing
Smart Wait is enabled by default in Project > Settings > Execution > WebUI. This default configuration will automatically download the Smart Wait extension and apply Smart Wait to all elements in that project.
A workaround to apply Smart Wait for remote execution
To apply Smart Wait for remote execution in Chrome for Katalon Studio before version 9.0.0.alpha1, follow these steps:
In the node machine:
Download a Katalon .zip package. You can download different versions of the Katalon package from our GitHub repository: Katalon releases.
Unzip the file and locate the Smart Wait folder. By default, you can find the Smart Wait folder at:
- For macOS:
<Katalon Studio folder>/Contents/Eclipse/configuration/resources/extensions/Chrome/Smart Wait
- For Windows:
<Katalon Studio folder>\configuration\resources\extensions\Chrome\Smart Wait
In the test runner machine: The test runner machine is where you install Katalon Studio and store the test scripts.
- Open Katalon Studio.
- Go to Project > Settings > Desired Capabilities > Remote, then fill in the following information:
- Remote Server URL:
http://localhost:port/wd/hub
- the URL of the hub machine. - Remote Server Type: Choose Selenium.
Click Add on the command toolbar, then input the following values:
Table 1 Name Type Value browserName string chrome goog:chromeOptions Dictionary Click More (...). In the pop-up Dictionary Property Builder dialog, click Add, then input values from Table 2. Table 2 Name Type Value args List load-extension=<the absolute path to the Smart Wait folder located in the node machine>
Temporarily turn off Smart Wait
You can use the enableSmartWait
and disableSmartWait
keywords to enable/disable Smart Wait during the test temporarily. Follow these steps:
Make sure the Default Smart Wait function is enabled in project settings. By enabling this function, Katalon Studio will automatically download and install the Smart Wait extension.
Use the
enableSmartWait
ordisableSmartWait
keywords to enable/disable Smart Wait on your target elements.In the following example, we first use the
disableSmartWait
keyword to disable Smart Wait at the beginning of the test temporarily.Then we use the
enableSmartWait
keyword to enable Smart Wait when setting text on theUsername
object. Smart Wait is enabled until thedisableSmartWait
keyword is applied.WebUI.disableSmartWait()
WebUI.openBrowser('')
WebUI.navigateToUrl('https://store.katalon.com/')
WebUI.maximizeWindow()
WebUI.click(findTestObject('signin-link'))
WebUI.enableSmartWait()
WebUI.setText(findTestObject('username'), 'demo@katalon.com')
WebUI.setEncryptedText(findTestObject('password'),'3zBGMH+v8QQXwX1AbEAx2g==')
WebUI.click(findTestObject('signin-button'))
WebUI.click(findTestObject('menu-dropdown'))
WebUI.click(findTestObject('dashboard-item'))
WebUI.click(findTestObject('plugins-item'))
WebUI.disableSmartWait()
WebUI.closeBrowser()