When the test having if- else statement is executed and when the else part is executed , the test case shows failed status

Hi ,

I am trying to execute a test case which has if else statement.
So for my test some times if condition is true some time else part is true
when the if part is false and else part is executed , the test is marked has failed even though all steps pass actually.
It marks the last step has failed and in result log it shows the reason of failure for last step is because the if statement was false.

Following is accepted

But last case test fails because of the if condition is false

Every verifyXxx() keyword throws an exception by default. But when you use decision statement, you may expect it to fail under some specific conditions.

So, when you expect that this keyword fails (and it is valid scenario in the test context), add FailureHandling.OPTIONAL as third argument to your keyword.

WebUI.verifyElementInViewport(to, 1, FailureHandling.OPTIONAL)