> For the complete documentation index, see [llms.txt](https://docs.precisiontestautomation.in/scriptlessautomation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.precisiontestautomation.in/scriptlessautomation/automation-platforms/scriptlessweb-automation/web-dependent-test-case.md).

# Web Dependent Test Case

### Overview

The `DEPENDANT_TEST_CASE` feature in web automation allows the reuse of a set of pre-defined test steps from one test case within another. This enables the execution of common setup steps without duplicating code, saving time, and increasing the maintainability of test suites.

### How It Works

`DEPENDANT_TEST_CASE` is used within a test script to call and execute steps from an existing test case. When called, it runs all steps from the dependent test case up to, but not including, the validation steps. This feature is designed to set up a test environment by reusing actions from a reliable, previously executed test.

### Implementation

To implement a `DEPENDANT_TEST_CASE`, you should:

1. Identify the common steps that are used across multiple test cases.
2. Create a base test case script with these steps.
3. Call this base test case at the beginning of other test scripts using the `DEPENDANT_TEST_CASE` action.

#### Example Implementation

**Base Test Case: search\_sanity.csv**

{% code lineNumbers="true" fullWidth="true" %}

```
PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
NONE,NONE,NONE,NONE,LOAD_URL,https://www.saucedemo.com/,NONE,NONE
SwagLabs,VISIBILITY,NONE,pageTitle,NONE,NONE,Swag Labs,EQUAL_IGNORE
```

{% endcode %}

**Dependent Test Case: fillUserDetails\_Sanity.csv**

{% code lineNumbers="true" fullWidth="true" %}

```
PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
NONE,NONE,NONE,NONE,DEPENDANT_TEST_CASE,search,NONE,NONE
SwagLabs,VISIBILITY,NONE,userName,SEND_KEYS,testuser,NONE,NONE
SwagLabs,VISIBILITY,NONE,password,SEND_KEYS,testpassword,NONE,NONE
SwagLabs,VISIBILITY,NONE,loginButton,CLICK,NONE,NONE,NONE
SwagLabs,VISIBILITY,NONE,errorMessage,NONE,NONE,Epic sadface: Username and password do not match any user in this service,EQUAL_IGNORE
```

{% endcode %}

### Usage

When creating a new test script that requires steps from an existing test case, use the `DEPENDANT_TEST_CASE` in the first step of the CSV file to call the necessary base test case.

### Benefits

* **Reduces Redundancy**: Eliminates the need to rewrite common steps for each test.
* **Saves Time**: Decreases the overall test script development and maintenance time.
* **Increases Reliability**: Utilizes steps from stable test cases, ensuring consistency across tests.

### Considerations

* When a dependent test case is called, validations are not executed to allow for different validations in the new test case.
* If the base test case is modified, all dependent test cases must be reviewed to ensure they function as expected.

### Troubleshooting

* **Issue**: Dependent test case does not execute.
  * **Resolution**: Check the reference to the dependent test case name for accuracy and ensure it is correctly placed in the CSV file.
* **Issue**: Validation steps from the dependent test case are being executed.
  * **Resolution**: Ensure that the dependent test case is structured to end before validation steps, or that the calling test case properly handles the flow.

### Reports

{% file src="/files/oUJ4dZAFGElhZMl2Lv21" %}

### Demo

{% embed url="<https://youtu.be/Og6xVIGpPf8>" %}
Demo
{% endembed %}

### Conclusion

The `DEPENDANT_TEST_CASE` feature is a key element in creating efficient and maintainable web automation tests. By leveraging this feature, testers can construct robust test suites that are easier to manage and scale.

### Tutorial

{% embed url="<https://youtu.be/SgxgHDhD2d4?feature=shared>" %}


---

# 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.precisiontestautomation.in/scriptlessautomation/automation-platforms/scriptlessweb-automation/web-dependent-test-case.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.
