For the complete documentation index, see llms.txt. This page is also available as Markdown.

Dynamic Selectors

Dynamic Selectors make automated tests more resilient by allowing selectors to use variables instead of fixed values.

This is useful when applications display dynamically generated content such as project names, customer names, order numbers, or other data that changes between test runs.

Instead of locating an element using a fixed value:

Then "Project Demo123" is displayed

you can reference a variable:

Then "Project {{projectName}}" is displayed

At runtime, TestFirst automatically replaces the variable with its current value before locating the element.

Create a Dynamic Selector

Dynamic Selectors can be created while recording a test.

  1. Start Recording a test in the TestFirst Editor. The Recorder toolbar appears.

  2. Right-click the action you want to record (for example, Click or Validate).

  3. Select Dynamic selector.

  4. Click the target element in the application.

TestFirst records the action using a variable-aware selector instead of a fixed value.

Tip: The Validate action records a Then "..." is displayed assertion. Right-click Validate and select Dynamic selector to create a dynamic validation.

Use an Existing Variable

If you want to bind the selector to an existing variable:

  1. Add a variable assignment before the recorded action, for example:

  1. Run the test up to that step so the variable is available in the current recording session.

  2. Record the Dynamic Selector as described above.

TestFirst uses the variable value when creating the selector, allowing the same test to work with different application data.

AI-assisted Dynamic Selectors

Dynamic Selectors work with AI-generated element descriptions on web applications.

When the Recorder detects dynamic values, it can generate selectors that use variables, making recorded tests more resilient to changing application data.

Example

The same test can now run repeatedly without updating selectors when the project name changes.

Dynamic Selectors reduce maintenance by making automated tests resilient to dynamically generated application data.

Last updated