Adding If, Else, Else If Conditions in Test Cases


In Testsigma, you can add If, Else, and Else If in your test cases based on a true or false condition. For example, If verifies the login status in a login test case, and Else will check credentials and redirections. This article discusses using If, Else, and Else If Conditions in Testsigma.


Prerequisites


Using If, Else and Else If conditions in Test Cases

  1. Navigate to Create Tests > Test Cases, and click on Create Test Case. Navigate to Test Cases
  2. Create a test step to navigate to the URL. Example: https://travel.testsigma.com/login Test Step
  3. Click on the option on the left side of the test step. This will open a side panel. Side Panel
  4. Hover over to the Conditional Step Types and click on If Natural Language. If Natural Language
  5. This will add an IF condition to your test step. If Condition
  6. Now add the test step within the IF statement by choosing the specific NLP. NLP with IF
  7. Hover over the test step and click on Step Inside IF to add sub-steps under the IF condition. Step Inside IF
  8. This will create a test step number 2.1 which will be under step 2. Step 2.1
  9. You can continue to add sub steps numbered as 2.2, 2.3, etc. The test steps numbers 2.2, 2.3, etc will be executed only if the Conditional IF is true. Conditional IF Steps

Here’s a quick GIF demonstrating how to create Conditional IF test steps. Conditional IF Steps


Creating “Else If” or “Else” Conditions

  1. Create IF condition in the test step and hover over the IF statement, you will see Else If and Else. Else if, Else
  2. Click on either Else If or Else to create a test step. All other steps are the same as mentioned in the previous section of this article. Else

The screenshot above shows the usage of Else If condition.


Using Testsigma’s Test Step Recorder for If Conditions [Web and Mobile Web]

We can also add the If Condition while creating test steps using Testsigma’s test recorder. Follow the steps below to add the If condition using recorder.

  1. Navigate to Create Tests > Test Cases, and click on Create Test Case. Navigate to Test Cases
  2. On Test Case details page, click on Record. Record
  3. A new window will be opened along with the test step recorder. Window
  4. Enter the URL https://travel.testsigma.com/login and navigate to the page. This will automatically open the site record a test step in the test step recorder sub-window. Recorder Window
  5. Click on the option on the left side of the recorder and enable the Conditional If toggle. Conditional If
  6. Record the steps and click on Done. Done

For more information on creating steps using recorder, refer to recording test steps.

Here’s a quick GIF demonstrating how to add If conditions for web apps using recorder. Conditional IF for Web & Mobile Web


Using Testsigma’s Test Step Recorder for If Conditions [Mobile Apps]

  1. Navigate to Create Tests > Test Cases, and click on Create Test Case. Navigate to Test Cases
  2. Click on Record. Record
  3. Record the steps and stop the recorder. Record Steps