Object Not found error

I have 2 different pages which contains Print button in one page & View button in another page. When user clicks on any of these buttons a PDF report will be downloaded and validating the heading in the report. I have developed a keyword and calling the function in both test cases. Calling both the controls in the same keyword and below is the code.
String buttonView = ‘’
String buttonPrint = ‘’
if (WebUI.verifyElementVisible(findTestObject(‘btn_View’)) == true) {
buttonView = WebUI.getAttribute(findTestObject(‘btn_View’), ‘value’, FailureHandling.CONTINUE_ON_FAILURE)
}
else if (WebUI.verifyElementVisible(findTestObject(‘a_ACSPrint’)) == true) {
buttonPrint = WebUI.getAttribute(findTestObject(‘a_ACSPrint’), ‘id’, FailureHandling.CONTINUE_ON_FAILURE)
}

When I execute Print button test case, it is executed successfully but seeing the below error as View button is not present in this page.

2022-06-23 13:14:05.178 INFO c.k.k.c.webui.common.WebUiCommonHelper - Unable to find the element located by ‘By.xpath: //input[@type = ‘button’ and @value = ‘View’]’. Please recheck the objects properties to make sure the desired element is located.
2022-06-23 13:14:05.717 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Web element with id: ‘Object Repository/Reports/Enforcement/Person Matching Exceptions/btn_View’ located by ‘//input[@type = ‘button’ and @value = ‘View’]’ not found (Root cause: com.kms.katalon.core.exception.StepFailedException: Web element with id: ‘Object Repository/Reports/Enforcement/Person Matching Exceptions/btn_View’ located by ‘//input[@type = ‘button’ and @value = ‘View’]’ not found

Note: If I run the View test case not seen any error.

Please suggest how to fix this error.

Thanks in advance!!!

2 Likes

Hi @usekatalon, thank you for sharing this with our Katalon Community. It would be helpful if you can share with us your execution video. Also, can I double check with you where are you executing the test? On local environment or where else?

Best,
Vu Tran