Test object return null and test fail

Hi!

I have this problem:

If Object A is present, then click it.
If Object A is no present, then click Object B

In the ‘if’, i have a “VerifyElementPresent(Object A)”
But when the verification start, return a null and just fail.

If i wrote the verification as optional, is a solution. But this generate a useless screenshot on the report.

Any ideas?

What do you mean generates a useless screenshot? and either optional or continue on failure. if not it has to do something if it fails. stop, continue, or optional. stop is probably your default setting. Since it’s part of your if condition, I’m not sure why you are getting a screenshot.

I mean is useless for me getting a screenshot for something optional (in my case)
I have the option to take a it in the project settings when it fails, so optional failure take the screenshots too (for me, in my project is useless)

Is Object A present in the object repository, and if so, does the path to Object A in the script for the test case match where the object is actually located in the repository? This can happen if you move or delete objects in the repository after the test case has already been created.

Maybe posting the script here for the problematic steps can help us solve the problem, too.

1 Like

Yes I agree with @michael.hollander seeing the script might help. I am curious what your if statement looks like.

Have you tried

if (WebUI.VerifyElementPresent(Object A, 0, FailureHandling.OPTIONAL) == true) {
}

If you just do

if (WebUI.VerifyElementPresent(Object A, 0, FailureHandling.OPTIONAL) ) {
}

It might be utilizing the webUI verify instead of the Boolean of true for the if need.