If else in Tosca is used to control the flow of the script using a defined condition.
In the below example, we are trying to log in to the Demo webshop, and below is the if condition structure
If (Error Condition == “”)
Then (Verify user logged in successfully)
Else (Verify error message for invalid user)
How to create if else in Tosca
Right-click on the folder and in Ribbon click if the condition icon
In the Condition block, Add the TBox evaluation tool and give the required condition in it, and in the block mention what set of validations needs to be done if the condition gets passed
Right-click on the if condition and select the else block from the Ribbon menu
In this example, We passed an invalid username and password. Based on the above condition we provided, we expect the condition to fail and the script should proceed with else block
I hope the article was useful. Kindly reach out to us if you have any issues with Tosca
Best Practice :- In Tosca, if condition should be used only if you don’t have any alternative options like TestCaseDesign conditions