> 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/dynamic-strings.md).

# Dynamic Strings

Our automation tool is equipped with a robust system that allows for dynamic data handling based on the specified environment. This functionality ensures that the tool is flexible and can cater to various conditions such as development, testing, or production environments. Below is a detailed explanation of how this system works:

#### Environment-Specific Directories

Each environment, such as QA or sandbox, has a corresponding directory under the `test_data` folder. These directories contain property files which hold data pertinent to their respective environments. For example:

* `test_data/qa` contains property files for the QA environment.
* `test_data/sandbox` contains property files for the sandbox environment.

<div align="left"><figure><img src="https://1894392350-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiGaaGnfeM1ej74weWKLs%2Fuploads%2F0BoZcObcjPbzBv5RSdpv%2FScreenshot%202024-03-04%20at%2011.16.15%20PM.png?alt=media&amp;token=46617b60-0293-4602-b890-5a106cf49956" alt=""><figcaption></figcaption></figure></div>

#### TestNgConfiguration Properties

The `TestNgConfiguration.properties` file is pivotal in determining which environment's data is to be utilized during test execution. It contains a key named `ENV` whose value is the name of the directory (environment) that the automation tool should reference. For example:

* Setting `ENV = qa` in `TestNgConfiguration.properties` will instruct the tool to use data from the `test_data/qa` directory.

<figure><img src="https://1894392350-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiGaaGnfeM1ej74weWKLs%2Fuploads%2FOM1jwaG2joZqESoG0URG%2FScreenshot%202024-03-04%20at%2011.18.30%20PM.png?alt=media&amp;token=0185df16-46b9-4fb4-b6ee-6195ec856588" alt=""><figcaption></figcaption></figure>

#### Dynamic Data Retrieval Process

When the automation suite is run, it reads the `ENV` property and dynamically selects the appropriate property files from the specified environment's directory. The data within these property files can be accessed using a unique syntax in the automation scripts:

* `$` denotes the start of a dynamic string.
* `text` represents the name of the properties file (without the extension).
* `title` is the key within the property file whose value you want to retrieve.

For example, `$text.title` will fetch the value associated with the key `title` from the `text.properties` file in the active environment directory.

<figure><img src="https://1894392350-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiGaaGnfeM1ej74weWKLs%2Fuploads%2F1B4q2qd5wDSgvPFZBcYi%2FScreenshot%202024-03-04%20at%2010.28.04%20PM.png?alt=media&amp;token=80fee86e-aa7f-47d3-8580-10ffc20e8cf2" alt=""><figcaption></figcaption></figure>

#### Consistency Across Environments

To ensure the automation tool functions correctly, it is crucial that each environment directory contains property files with the same names. This consistency allows the tool to switch environments seamlessly without any changes to the automation scripts.

<figure><img src="https://1894392350-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiGaaGnfeM1ej74weWKLs%2Fuploads%2F6xfUkHgaKkUQySzG4XaK%2FScreenshot%202024-03-04%20at%2011.21.02%20PM.png?alt=media&amp;token=ed483a93-ee93-40c8-938f-5a812d337c81" alt=""><figcaption></figcaption></figure>

#### Use in SEND\_KEYS and VALIDATION

This dynamic string substitution is not only limited to reading data; it is also applicable to operations like `SEND_KEYS` and `VALIDATION`. When a script is required to input or validate data, it can refer to these dynamic strings to get environment-specific values, thereby maintaining the flexibility and accuracy of test cases.

* `SEND_KEYS`<br>

  <figure><img src="https://1894392350-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiGaaGnfeM1ej74weWKLs%2Fuploads%2FwA6dLLWqgmohxbvD2GD3%2FScreenshot%202024-03-04%20at%2011.23.42%20PM.png?alt=media&amp;token=19cd9938-349b-41cd-8bf7-324a3b699a6a" alt=""><figcaption></figcaption></figure>
* `VALIDATION`<br>

  <figure><img src="https://1894392350-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiGaaGnfeM1ej74weWKLs%2Fuploads%2FkwSd6VYnVHEiZSWPCh8N%2FScreenshot%202024-03-04%20at%2011.24.24%20PM.png?alt=media&amp;token=8e2c949a-7e40-4e7a-8022-bf2bee4af95f" alt=""><figcaption></figcaption></figure>
