Locators and Variables

Updated 4 months ago by Elena Illán


Locators are the expressions that select which HTML element a command refers to. Selenium uses them to find and match the elements of the page that it needs to interact with. 

The format of a locator is:


Using the right locator ensures the tests are faster, more reliable or has lower maintenance through the releases. For this purpose, and in addition to the standard Selenium locators (listed on  Selenese command reference), we offer the Copado locators, with the next format:


Locators in Test Cases

From the Copado Selenium Testing app, press the "Test Cases" tab. Select one from the list, or create a new one. To learn how to record a Test Case, see   Selenium Test Cases.

When you record a Test Case, all actions you performed are stored in the Test Case record.  The locators are generated also in every recording step. As can be seen in the next picture from a Test Case screen, they are stored in the "PARAM 1/TARGET" column. 

This is a list of the locators that can be found depending on the type:

  • copado=field:*Project Name
  • copado=link#2:{!RUN_ID} Test Project
  • copado=button:Save
  • copado=tab:Projects
  • copado=app:Copado Change Management
  • copado=detail:Git Snapshot Name
  • copado=popup:Project

Locators are easy to edit from Copado Selenium Recorder or just clicking on “Edit” button in the Test Case. In case the element is not detected by the test, select another one from the drop-down menu:

     In different environments, elements may have different identifiers, so the locators' list is useful when you need to select a more specific one and ensure it works on every environment.

    Locator Tab

We can access to the locators also in the Selenium Locators tab.
From the Copado Selenium Testing app, press the "Selenium Locators" tab.  Once there, select one of them and click on "Related". There we can see the Test Case where the locator is being used.

They can also be used in a Test Case as {!Locator.LOCATOR_ID}. This allows to name/manage the locators across multiple test cases in a central location.  To assign an ID to the locator, get into its Edit screen and create it.


Variables represent text strings to be replaced at the time of the execution of a test case.

We have pre-defined variables ready to be used... 

  • {!NS} Namespace defined in the  Copado Environment record.
  • {!RUN_ID} unique number per Test Run, useful to generate unique Name values
  • {!BLANK} If you need to execute a command with a blank value (to set a field as empty, for example), you can use this variable.
  • Date and datetime variables: {!TODAY}, {!TODAY-1} (yesterday), {!NOW},  {!NOW+1}.
  • Group variables, defined in a  Selenium Test Group{!Group.VARIABLE}.

... and from the Copado Recorder page, you can create and use variables as you need. To do that:

  •  In the command column, you can use the store commands listed on Selenese Command Reference to create new variables.
  • In the param 1/target column, we will assign a value to the variable.
  • In the param 2/value column, we will provide its name. The variable names must start with a letter, cannot contain whitespaces or non-alphanumeric characters except _).

The next picture is an example of this process:

In order to use a variable, its syntax can be any of these ones:

  • {!variablename}
  • ${variablename}
  • storedVars.variablename

How did we do?