When using verifyElementAttributeValue(), if a web element does not contain the desired attribute value then the test case fails as expected. However if the xpath cannot be found then a warning is displayed and the test case passes, regardless of the attributes value. My current work around to this problem is to verify that the element is present before verifying the elements attribute value. This way the test will fail if the web element cannot be found, or if the web element does not contain the correct attribute value. Is there a way to fail a test if the element cannot be found or if the element does not contain the desired attribute value using verifyElementAttributeValue()?
Exception Handling Statements
@Chriscph1, verifyElementAttributeValue does not fail a test if the element cannot be found. Your workaround should be an acceptable solution in this case.
Is Katalon planning on fixing this problem? My workaround works well when verifying that a few input fields are disabled, but today I am verifying about 50 disabled input fields and verifying that all of them are present and contain the readonly attribute value is making my test case look messy and hard to read. Also, I assume that most people who use verifyElementAttributeValue are not aware that you need to also verify that the element is present.
If the failure handling is set to stop on failure, I would assume that if an element is not found the test case would be stopped.
WebUI.verifyElementHasAttribute(findTestObject(’…’), ‘readonly’, 5, FailureHandling.STOP_ON_FAILURE)