Is there a way to have Katalon processing wait until a specific button is actually pressed before continuing? I can verify it but that does not address my problem. I have a situation where a user gets to a UI page and then enters some data into a text block. Whenever the user finishes, they press a “Continue” button. For some reason this function doesn’t work after a Chrome driver update. Now the process completes without waiting for the “Continue” button to be pressed. I tried a hard WebUI.delay(20) but that is not a good solution. Any ideas?
If the user is navigated to a new page when they press “Continue” you can always use a Wait For Element Not Visible. That way you can set a timeout but the test will continue as soon as the “Continue” button is no longer visible.
What action is to happen after the user clicking “Continue”?
If it’s “submit and go to the next page”, then you may want to check this code snippet out (this is how I handle the problem in my real codebase):
public final class GeneralWebUIUtils {
public static final String DISABLED = "disabled";
private static boolean WaitForURLCondition(Closure<Boolean> onCheckCondition, int timeOut, Closure<String> onErrorMessage, FailureHandling failureHandling = FailureHandling.STOP_ON_FAILURE) {
final long startTime = System.currentTimeMillis()
boolean isConditionSatisfied = false;
while ((System.currentTimeMillis() < startTime + timeOut * 1000) && (!isConditionSatisfied)) {
isConditionSatisfied = onCheckCondition(WebUI.getUrl())
}
if ((!isConditionSatisfied) && (failureHandling.equals(FailureHandling.STOP_ON_FAILURE))) {
KeywordUtil.markFailedAndStop("${onErrorMessage(WebUI.getUrl())} after ${(System.currentTimeMillis() - startTime) / 1000} seconds");
}
return isConditionSatisfied;
}
public static boolean WaitForURLNotEquals(String url, int timeOut, FailureHandling failureHandling = FailureHandling.STOP_ON_FAILURE) {
return this.WaitForURLCondition({ String browserURL ->
return !(browserURL =~ SMDStringUtils.GetURLPattern(url)).matches();
},
timeOut, { String browserURL ->
"URL '${browserURL}' matches unexpected '${url}'"
},
failureHandling)
}
public static boolean WaitForURLEquals(String url, int timeOut, FailureHandling failureHandling = FailureHandling.STOP_ON_FAILURE) {
return this.WaitForURLCondition({ String browserURL ->
return (browserURL =~ SMDStringUtils.GetURLPattern(url)).matches();
},
timeOut, { String browserURL ->
"URL '${browserURL}' does not match expected '${url}'"
},
failureHandling)
}
public static void HandleSaveButton(TestObject saveButton) throws StepFailedException {
this.HandleSaveButton(saveButton, true);
}
public static void HandleSaveButton(TestObject saveButton, boolean shouldSuccessfullySave) throws StepFailedException {
WebUI.scrollToElement(saveButton, 3)
WebUI.waitForElementClickable(saveButton, 3, FailureHandling.STOP_ON_FAILURE);
WebUI.click(saveButton)
WebUI.waitForElementHasAttribute(saveButton, GeneralWebUIUtils.DISABLED, 5, FailureHandling.STOP_ON_FAILURE);
if (shouldSuccessfullySave) {
WebUI.waitForElementNotPresent(saveButton, 5, FailureHandling.STOP_ON_FAILURE);
WebUI.waitForPageLoad(5);
}
}
}
public final class SMDStringUtils {
public static String GetURLPattern(String url) {
return (/^(http(s)?\:\/\/)?${url}(\/)?$/);
}
}
Then, in your test case, you can just be like:
final String formPageUrl = WebUI.getUrl();
GeneralWebUIUtils.HandleSaveButton(saveButton); // replace with the TestObject for your "Continue Button"
GeneralWebUIUtils.WaitForURLNotEquals(formPageUrl, 15);
and move on with the rest of the test case!
DISCLAIMER: You’ll want to save these util classes as Keywords.