> For the complete documentation index, see [llms.txt](https://docs.walnutai.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.walnutai.ai/test-and-quality-management/test-management/add-control-flow-conditional-statements.md).

# Add Control Flow (Conditional Statements)

Adding a Control Flow (Logical Conditions) allows you to introduce conditional logic inside a test case to control execution based on defined conditions. It helps create dynamic, intelligent, and flexible test scenarios without writing manual code.

Control Flow is useful when certain steps should execute only under specific conditions, such as validating error messages, handling optional flows, retrying actions, or managing dynamic application behaviour.

**To add a control flow:**

* Hover over the desired test step and click the branching icon.
* Choose one of the available options:

  * [**If / Else**](/test-and-quality-management/test-management/add-control-flow-conditional-statements/if-else.md)
  * [**While Loop**<br>](/test-and-quality-management/test-management/add-control-flow-conditional-statements/while-loop.md)

  <figure><img src="/files/ysJEPhJ0KJdlK52PdYvy" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.walnutai.ai/test-and-quality-management/test-management/add-control-flow-conditional-statements.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
