2

When running the following code (in Katalon Studio):

if (WebUI.verifyElementPresent(findTestObject('Object Repository/xyz'), 
    5, FailureHandling.OPTIONAL)) {
    WebUI.click(findTestObject('xyz'))
}

I received the following error message:

Test Cases/abc FAILED because (of) Unable to click on object 'Object 
Repository/xyz' (Root cause: org.openqa.selenium.ElementNotVisibleException: 
element not visible)

So, even though the presence of the object is optional, I get an error message. Did you have a similar case?

3
  • the presence of the object is optional what tells you that the presence is optional?
    – Adelin
    Feb 16, 2018 at 13:35
  • 1
    It tells me that it's not mandatory to handle failures
    – Adelin
    Feb 16, 2018 at 13:48
  • 1
    My intention with this code is: "if the element is present, click it, if not continue...". So, if the element is not present, why should I get this error message, shouldn't it just continue with code execution?
    – Mate Mrše
    Feb 19, 2018 at 9:12

2 Answers 2

1

Your element seems to be present, but unreachable.

Use verifyElementClickable(...) instead of verifyElementPresent(...)

Documentation:

Reference Document

0

Your element might be present but maybe hidden. Use verifyElementVisible instead, e.g:

if (WebUI.verifyElementVisible(findTestObject('Object Repository/xyz'), 
    FailureHandling.OPTIONAL)) {
    WebUI.click(findTestObject('Object Repository/xyz'))
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.