waitForElementVisible is not stopping the scripts

Hello all,

I am using an method ‘waitForElementVisible’ and i added FailureHandling condition as STOP ON FAILURE.

Expected: Test should fail and should throw Step failed exception.
Actual: Status is showing as ‘Passed’

Will ‘Stop on failure’ failure handling condition works on wait statements?

If the element is not visible the step will fail without you needing to add a FailureHandling, the element may still be visible even though it is invisble to you which is why the step is passing - try WaitForElementPresent instead

I have used WaitForElementPresent still it is passed.

I think if Waiting for Element Visible/Present truly had these issues, these forums would be overrun with bug reports.

Post the entire content of the warning issued to the console instead of a cut-off image.

2019-02-19 13:11:39.035 e[39mDEBUGe[0;39m e[36mtestcase.New Test Case -e[0;39m e[39m3: waitForElementVisible(findTestObject(“Objects/Attributes Page/AttributeCode”), 10, STOP_ON_FAILURE)e[0;39m
2019-02-19 13:11:49.422 e[34mINFO e[0;39m e[36mc.k.k.c.webui.common.WebUiCommonHelper -e[0;39m e[39mUnable to find the element located by ‘By.xpath: //input[@name=‘codeField’]’. Please recheck the objects properties to make sure the desired element is located. e[0;39m
2019-02-19 13:11:49.422 e[31mWARN e[0;39m e[36mk.k.c.w.k.b.WaitForElementVisibleKeyword -e[0;39m e[39mWeb element with id: ‘Object Repository/Objects/Attributes Page/AttributeCode’ located by ‘By.xpath: //input[@name=‘codeField’]’ not founde[0;39m
2019-02-19 13:11:49.423 e[39mDEBUGe[0;39m e[36mtestcase.New Test Case -e[0;39m e[39m4: closeBrowser()e[0;39m
Test Cases/New Test Case
PASSED
2019-02-19 13:11:50.173 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[39mEND Test Cases/New Test Casee[0;39m

@Sudheer_D_J, “waitForElementVisible” is just used for synchronization purpose. It will prevent your test from failing when following steps are executed without necessary elements being loaded. Therefore, it should not make the test fail if the element is not visible. To get pass/fail result based on the visibility of an element, use “verifyElementVisible” instead.
You can refer to https://docs.katalon.com/katalon-studio/docs/webui-wait-for-element-visible.html#description and https://docs.katalon.com/katalon-studio/docs/webui-verify-element-visible.html#description for more details.

2 Likes

Just gonna leave this here…

tl;dr The wait and verify family of methods could use a refactor to reduce user confusion.

2 Likes

Thanks for your reply

Thanks for your reply!!

If the “wait for” keyword is intended to be used this way, it should be reflected in the docs.

The flowControl parameter description states:

Specify failure handling schema to determine whether the execution should be allowed to continue or stop

This implies the use of flowControl can be used to mark the keyword as failed and stop execution.

The log output below shows waitForElementVisible being called on an element that is not present. It is called 3 times to show the result of all failure handling options. A WARN is thrown regardless of the setting and the execution continues. So why is this parameter offered in the first place?

2019-09-27 16:22:30.358 DEBUG testcase.Open browser to DV2 - 5: waitForElementVisible(findTestObject(“Login/button_Login”), 2, CONTINUE_ON_FAILURE)
2019-09-27 16:22:30.363 DEBUG c.k.k.core.testobject.ObjectRepository - Finding Test Object ‘Object Repository/Login/button_Login’
2019-09-27 16:22:30.522 DEBUG c.kms.katalon.core.helper.KeywordHelper - Checking object
2019-09-27 16:22:30.523 DEBUG c.kms.katalon.core.helper.KeywordHelper - Checking timeout
2019-09-27 16:22:30.525 DEBUG c.kms.katalon.core.helper.KeywordHelper - Checking timeout
2019-09-27 16:22:30.530 DEBUG c.k.k.c.webui.common.WebUiCommonHelper - Finding web element with id: ‘Object Repository/Login/button_Login’ located by ‘By.xpath: //button[@type = ‘submit’ and (text() = ‘Log in’ or . = ‘Log in’)]’ in ‘2’ second(s)
2019-09-27 16:22:32.584 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.xpath: //button[@type = ‘submit’ and (text() = ‘Log in’ or . = ‘Log in’)]’. Please recheck the objects properties to make sure the desired element is located.
2019-09-27 16:22:32.600 WARN k.k.c.w.k.b.WaitForElementVisibleKeyword - Web element with id: ‘Object Repository/Login/button_Login’ located by ‘By.xpath: //button[@type = ‘submit’ and (text() = ‘Log in’ or . = ‘Log in’)]’ not found
2019-09-27 16:22:32.601 DEBUG testcase.Open browser to DV2 - 6: waitForElementVisible(findTestObject(“Login/button_Login”), 2, OPTIONAL)
2019-09-27 16:22:32.602 DEBUG c.k.k.core.testobject.ObjectRepository - Finding Test Object ‘Object Repository/Login/button_Login’
2019-09-27 16:22:32.660 DEBUG c.kms.katalon.core.helper.KeywordHelper - Checking object
2019-09-27 16:22:32.661 DEBUG c.kms.katalon.core.helper.KeywordHelper - Checking timeout
2019-09-27 16:22:32.661 DEBUG c.kms.katalon.core.helper.KeywordHelper - Checking timeout
2019-09-27 16:22:32.661 DEBUG c.k.k.c.webui.common.WebUiCommonHelper - Finding web element with id: ‘Object Repository/Login/button_Login’ located by ‘By.xpath: //button[@type = ‘submit’ and (text() = ‘Log in’ or . = ‘Log in’)]’ in ‘2’ second(s)
2019-09-27 16:22:34.699 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.xpath: //button[@type = ‘submit’ and (text() = ‘Log in’ or . = ‘Log in’)]’. Please recheck the objects properties to make sure the desired element is located.
2019-09-27 16:22:34.700 WARN k.k.c.w.k.b.WaitForElementVisibleKeyword - Web element with id: ‘Object Repository/Login/button_Login’ located by ‘By.xpath: //button[@type = ‘submit’ and (text() = ‘Log in’ or . = ‘Log in’)]’ not found
2019-09-27 16:22:34.701 DEBUG testcase.Open browser to DV2 - 7: waitForElementVisible(findTestObject(“Login/button_Login”), 2, STOP_ON_FAILURE)
2019-09-27 16:22:34.701 DEBUG c.k.k.core.testobject.ObjectRepository - Finding Test Object ‘Object Repository/Login/button_Login’
2019-09-27 16:22:34.756 DEBUG c.kms.katalon.core.helper.KeywordHelper - Checking object
2019-09-27 16:22:34.756 DEBUG c.kms.katalon.core.helper.KeywordHelper - Checking timeout
2019-09-27 16:22:34.756 DEBUG c.kms.katalon.core.helper.KeywordHelper - Checking timeout
2019-09-27 16:22:34.757 DEBUG c.k.k.c.webui.common.WebUiCommonHelper - Finding web element with id: ‘Object Repository/Login/button_Login’ located by ‘By.xpath: //button[@type = ‘submit’ and (text() = ‘Log in’ or . = ‘Log in’)]’ in ‘2’ second(s)
2019-09-27 16:22:36.796 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.xpath: //button[@type = ‘submit’ and (text() = ‘Log in’ or . = ‘Log in’)]’. Please recheck the objects properties to make sure the desired element is located.
2019-09-27 16:22:36.797 WARN k.k.c.w.k.b.WaitForElementVisibleKeyword - Web element with id: ‘Object Repository/Login/button_Login’ located by ‘By.xpath: //button[@type = ‘submit’ and (text() = ‘Log in’ or . = ‘Log in’)]’ not found

I posted a bug report in may: WebUI.waitForElement*() not throwing exception
I still use my workaround in version KS_6.3.3

3 Likes