---
source_url: "https://testsigma.com/docs/elements/dynamic-elements/with-runtime-test-data/"
title: "Dynamic Locators using Runtime: Enhance Test Stability"
mirrored_at: 2026-08-15T01:09:06.549Z
host: testsigma.com
cited_in_42a: true
mirror_canonical: "https://index.42a.ai/testsigma.com/docs/elements/dynamic-elements/with-runtime-test-data/index"
---

> **Original source:** https://testsigma.com/docs/elements/dynamic-elements/with-runtime-test-data/

* * *

Dynamic locators are essential in handling web elements that may undergo attribute changes during test execution. Traditional locators like XPath or CSS selectors may lose reliability when these dynamic changes occur. Testsigma offers a solution that enables you to create dynamic locators at runtime, guaranteeing the stability and dependability of your automated tests. This documentation guides you through utilising dynamic locators in Testsigma by storing elements into Runtime Variables.

* * *

> Prerequisites
> 
> Before you begin, ensure that you have referred to:
> 
> 1.  [Documentation on creating test cases](https://testsigma.com/docs/test-cases/manage/add-edit-delete/#creating-a-test-case).
> 2.  [Documentation on managing runtime test data](https://testsigma.com/docs/test-data/types/runtime/).
> 3.  [Documentation on creating elements](https://testsigma.com/docs/elements/web-apps/capture-single-element/).
> 4.  [Documentation on creating test steps](https://testsigma.com/docs/test-cases/step-types/natural-language/).
> 5.  [Documentation on creating test data types](https://testsigma.com/docs/test-data/types/overview/).

* * *

## **Store Element into Runtime Variable**

We will manually create an element and store it in a Runtime Variable to create dynamic locators. This is important because recording dynamic elements may not be reliable.

1.  Create a **new step** in your **Test Case** using **NLP**. Use placeholders for **elements** and **test data** to create an element and store it as a Runtime Variable. ![Use Element Test Data NLP](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/update_dynamic_locator_1.png)
    
    Example:
    
    Use NLP "Store text from the **element** into a variable **test data**". The NLP helps you store text from an element identified into a variable.
    
2.  Click on the element, then select **Create** from the dropdown list. The Create Element overlay screen will appear on the right side of the page. ![Create](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/update_dynamic_locator_2.png)
3.  Manually enter the **Element Name**, **Screen Name**, **Element Type**, and **Element Value**. Finally, click **Create Element** to complete the element creation. ![Create Element to store](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/update_dynamic_locator_3.1.png)
4.  Substitute specific **text** for the **test data** placeholder and click **Create Step** to save the test step, storing the element within the text as a Runtime Variable. ![Store Element in Runtime](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/update_dynamic_locator_4.png)
    
    Example:
    
    -   We are using the **Simply Travel Flight** website as an example. If we want to locate the **Login or Sign Up** button and its XPath is **(//\*\[@id="login-signup"\]/div)**, we can store its value in a runtime variable **($|login|)**.
    -   When we run the test, we can use this variable to locate the button. If the value changes later, we can update it without affecting the test. This method works even if the button is used in different test steps and its value changes.
    

* * *

## **Creating Dynamic Elements using Runtime Test Data**

1.  Use **NLP** to create a **new step** in the **Test Case** and include a placeholder for the **element**. ![Use Element NLP](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/update_dynamic_locator_5.png)
    
    Example:
    
    Utilise NLP "Click on **Element**" to click an element with a given UI Identifier.
    
2.  Click on the element, then select **Create** from the dropdown list. The Create Element overlay screen will appear on the right side of the page. ![Create Element](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/update_dynamic_locator_6.png)
3.  Manually enter the **Element Name**, **Screen Name**, and **Element Type**.
4.  Provide Dynamic Element Value **//\*\[@id="$|login|"\]/div**, where '**login**' is the stored Runtime Variable. Click **Create Element** to complete element creation. ![create\_element using runtime](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/update_dynamic_locator_7.1.png)
    
    Example:
    
    During testing, accurately locate the actual 'Login or Sign Up' element on the Simply Travel Flight website with the dynamic XPath **//\*\[@id="$|login|"\]/div** using the Runtime Variable 'login'.
    

* * *

## **Implementing Dynamic Locators using Runtime**

With the Runtime Variable in place, follow these steps to implement dynamic locators in your test cases:

1.  Add a new step in the test case where interaction with the dynamic element is required.
2.  Manually select the dynamic element and proceed with your test steps. Testsigma will dynamically locate the element during test execution. ![Use Runtime for Elements](https://s3.amazonaws.com/website-static-docs.testsigma.com/new_images/projects/Updated_Doc_Images/update_dynamic_locator_8.png)

* * *