> For the complete documentation index, see [llms.txt](https://docs.simplifyqa.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.simplifyqa.ai/introduction-to-script-less-recording-of-test-case-in-simplifyqa/record-a-function.md).

# Record a Function

Reusable functions are modular units of code that can be defined once and used multiple times within your automation scripts, improving code structure and reducing redundancy.

In this section we will guide you through the process of recording a function which enhances code organization and maintainability.

### Prerequisites

* A clear understanding of the software feature or functionality you're testing.
* Access to the project for which you want to create automation test case and privilege to create function.
* SimplifyQA Wizard needs to be installed and running. Learn how to setup Wizard here [Setup QAWIzard](/simplifyqa-installation-and-setup.md).
* Before recording, identify the specific actions or sequences of steps that you want to reuse.

### How to Record a Function?

* **Launch the Recorder:** Locate the recorder icon and select the required technology and select 'Function' option to record the function.

<figure><img src="/files/3j2FYt6C2Hsb639VLmA8" alt=""><figcaption></figcaption></figure>

* **Define the Function Name:** Provide the name of the function and mention the URL of the application under test.

<figure><img src="/files/2rUErLCgEkexsROhZvhV" alt=""><figcaption></figcaption></figure>

* **Start Recording:** Click on start recording. Begin interacting with the application you want to test. The recorder will capture your actions, including clicks, keystrokes, navigation, etc.
* **Stop Recording:** Navigate back to SimplifyQA once you've completed the desired actions, stop the recording.
* **Review the Test Steps:** Review the recorded steps. Object and parameters names would be automatically captured with appropriate names. Data provided during the recording would also be captured in test data.
* **Define Function Details:**&#x20;
  * Specify the function name and module and save your function. Learn how to organise and manage functions here [Organise your Test Cases](/introduction-to-test-management-in-simplifyqa/organise-your-test-cases.md)[/Functions](/introduction-to-test-management-in-simplifyqa/organise-your-test-cases.md).
  * **Pre-requisites:** Any setup or conditions required before recording the function, you can mention them in the form of checklist.

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

<figure><img src="/files/317zKCh9VhOw8xnDUTmu" alt=""><figcaption></figcaption></figure>

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

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

{% hint style="info" %}
Learn how to organise and manage functions here [Organise your Test Cases](/introduction-to-test-management-in-simplifyqa/organise-your-test-cases.md)[/Functions](/introduction-to-test-management-in-simplifyqa/organise-your-test-cases.md).
{% endhint %}

### Benefits of Using Reusable Functions

* **Improved Code Organisation:** Functions help structure your scripts and make them easier to understand and maintain.
* **Enhanced Maintainability:** When making changes to a common set of actions, you only need to update the function once, reducing the risk of errors.
* **Increased Efficiency:** Reusing functions eliminates the need to record the same actions multiple times, saving time and effort.
* **Better Readability:** Functions provide a more concise and readable representation of your test cases.

{% hint style="success" %}
**Additional Tips**

* **Function Naming:** Choose descriptive names for your functions to clearly indicate their purpose.
* **Parameterisation:** Use parameters to make your functions more flexible and adaptable to different scenarios.
* **Error Handling:** Implement error handling mechanisms within your functions to gracefully handle unexpected situations.
  {% endhint %}

### Frequently Asked Questions (FAQs)

<details>

<summary>Can I add validations while recording a function?</summary>

Yes, all validations can be captured just like in a test case by using the same recording tools, including Double Shift for validations.

</details>

<details>

<summary>Can I use functions inside other functions?</summary>

Yes, SimplifyQA allows nesting functions within other functions. This helps in building modular and reusable logic structures. However, it’s important to ensure that the nesting is logical and does not create circular dependencies.

</details>

<details>

<summary>Can I delete a function?</summary>

Yes, but only if it’s not in use in any test case. SimplifyQA will prompt you if the function is referenced elsewhere.

</details>


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.simplifyqa.ai/introduction-to-script-less-recording-of-test-case-in-simplifyqa/record-a-function.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
