Set implicit wait for the driver

In selenium you have 2 types of waits : implicit and explicit
Only the explicit seems to be available, that means I need to set the wait for each action.
I can’t believe there is no integration of the implicit one since it’s a Selenium basic and so useful.
Cause now I need to edit each of my recorded scenarii to add the proper java code…

There are various built-in keywords for fluentwait in Katalon Studio, ie. waitForElementVisible, waitForElementClickable. It is useful to test WebApp

1 Like

Thanks for your reply :grinning:
But the thing is when I replay scenario it’s not working because the recorder write the things like this :
WebUI.click(findTestObject('Page_Example/button_New Example'))
So I need to add a wait before EVERY clicks (and as we record the tests to be played as a part of our CI there are A LOT)
So in every test case script I need to add this :
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import java.util.concurrent.TimeUnit
import org.openqa.selenium.WebDriver
WebUI.openBrowser(’’)
WebDriver driver = DriverFactory.getWebDriver()
driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS)
But it’s people without coding knowledge that will record all the test cases.
So I wonder how to tell Katalon once for all, that my implicit wait is 1s (as example).

Try go to Project, Settings, Execution
in WebUI, Delay between actions (in seconds) and set 1

Yes but it’s a “hard” one second between each actions, and not a “wait until” it slows down too much the tests.
I found a workaround :slight_smile: I created a new test listener with that code:
class TestListener {

@BeforeTestCase
def beforeTestcase(TestCaseContext testCaseContext) {
	WebUI.openBrowser('');
	WebDriver driver = DriverFactory.getWebDriver()
	driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS)
	WebUI.navigateToUrl(GlobalVariable.URL);
}

}

So it start by setting the implicit wait for each test case

1 Like

@christophe.bouillaud

Is this working for you still? I applied it to testlisteners but it doesn’t seem to apply it to the test case, it only works when I apply it directly in the test case.

Also, this is an old issue from Selenium, implicit waits always worked funky I guess due to how the page loaded behaved, I always had to use waitUntilElementPresent then issue a .click.

For example even when i use implicit wait directly in the testcase the same click fails, I have to use an actual delay to get it to work.

The following works for a 1 second delay.
How would I code it to do 1/2 second delay?

//Implicit wait
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import java.util.concurrent.TimeUnit
import org.openqa.selenium.WebDriver

WebUI.openBrowser('')
WebDriver driver = DriverFactory.getWebDriver()
driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS)
1 Like

does .5 not work? Or change the timeUnit to milliseconds and use milliseconds.

Thanks!
Should have thought of .5

Best regards,
Dave