What to do when Validation fails

Best practices, code snippets for common functionality, examples, and guidelines.
bollsx
Posts: 4
Joined: Tue Jan 14, 2020 9:23 pm

What to do when Validation fails

Post by bollsx » Tue Dec 22, 2020 5:55 pm

I have a validation action. How do I do something if the validation fails?
Merry Christmas

Steve Boll

theraviz
Posts: 111
Joined: Sun Apr 14, 2019 9:46 am

Re: What to do when Validation fails

Post by theraviz » Wed Dec 23, 2020 12:10 pm

If you want to fail the test case when the validation fails, use Report.Failure("Test Failed");

bollsx
Posts: 4
Joined: Tue Jan 14, 2020 9:23 pm

Re: What to do when Validation fails

Post by bollsx » Wed Dec 23, 2020 3:57 pm

Being new to all of this, are you talking about adding a Report action to my recording. How do I fire that action only if the validate fails?
Merry Christmas

Steve Boll

theraviz
Posts: 111
Joined: Sun Apr 14, 2019 9:46 am

Re: What to do when Validation fails

Post by theraviz » Thu Dec 24, 2020 7:23 am

bollsx wrote:
Tue Dec 22, 2020 5:55 pm
I have a validation action. How do I do something if the validation fails?
If you want to make the execution fail when the validation fails then use "Report.Fail" in the usercode.cs

Or if you dont want to make the execution fail but perform some action then use if-else statement in user code.

you can convert any action recodring to user code by right clicking the action in the recording and from the context menu select "Convert to user code". In the user code you can write the condition as your wish.