Programming & Logic Handling
Mastering If-Else Conditions in ContextQA for Flexible Test Automation
Mastering If-Else Conditions in ContextQA for Flexible Test Automation
Efficient software testing often means writing reusable and adaptable tests. In this tutorial, you’ll learn how to use if-else conditions within ContextQA to handle dynamic selections—like choosing different dropdown options based on parameters. This makes your step groups flexible, so you don’t need to write separate steps for every scenario.
Let’s walk through creating a step group with if-else logic, then see how to use it in your test cases.
On the dashboard, open the navigation menu and click the pencil icon to access your step groups.
Go to the Step Groups tab.
Click the step group you want to edit.

Review the steps—each represents a different dropdown option. Hover above the first step, click the comment icon, and select Conditional if to add a new if block.
Within this if block, add a step using NLP search: choose "Verify the source value equals the target value." Set source value to a runtime variable (for example, `qualification`) and target value to the option you want to check (like "skills").
Move the relevant selection step (e.g., Select Skill) under the if block by reordering.
Hover over the if step and select Else If. Add the same verification step, setting the target value to the next option (like "education"). Move the corresponding selection step under the else if block.
Repeat Else If for any additional dropdown options, each time adjusting the target value.
For the last dropdown option, hover over the last Else If step, select Else, and move the final selection step under this block.
Now your step group dynamically selects the appropriate dropdown value using if, else if, and else logic.
Go to the Test Cases section and open your test case.
Hover over the comment icon and select the Step group option.
Choose the step group you built with conditional logic.
Click the three dots to access parameters. For the `qualification` parameter, enter the value you want to test (e.g., "education").
Save. You’ll see confirmation that the runtime variable updated successfully.
Create the step run and execute the test. The test will select the correct dropdown option based on the parameter value.
If you specify “education,” the test will select that option; if you provide “skills,” it'll pick skills. If your parameter doesn’t match any if/else if branch, the else step runs.
Using if-else conditions in ContextQA streamlines your tests, making them reusable and easier to maintain—especially with dropdowns or multiple-choice inputs.
ContextQA’s support for Else If conditions means you’re not limited to only two options. This flexibility is vital for complex forms or workflows.
Great job! You’ve learned how to automate dynamic choices in your tests using if-else logic in ContextQA. In the next session, you’ll make your test cases even more flexible and maintainable.
Last updated