Target specific text for an element with the content selector

To ensure that Userlane finds the right element in every situation, you can use the content selector.

The content selector looks for visible text in the element that you’ve recorded. If the text matches your input, the element will be found.

Good to know:
  • Only use this option when you can’t select the element intuitively.

  • You can combine content with OR (e.g. element contains “Settings” or “Einstellungen” or “Configuración”). That means you can use content selectors even if your application has more than 1 language.

  • You can’t use “text does not contain”. The available options are “contains” and “matches”.

How to apply the content selector

Open the selector of the element by clicking on ‘Selector’ in the step options. Here you’ll see the selector code.

Add the code selector automatically

When Userlane detects a text, you have the option to click on “Add Content selector” below the code. This will automatically insert the content selector. If the “Add Content selector” is not available or the content of the element isn’t found, you can change the selector text manually.

Add the code selector manually
  • Add a comma at the end of the “orderNum” line 

  • Copy and paste this code just after the added comma:

"content": {
    "type": "contains",
    "value": "Insert your text here"
}
  • Replace the “insert your text here” part with the content you want the selector to look for (e.g. “Settings”).

  • Click “Apply” to save your selector. Open it again to confirm that your changes were saved.

How to use OR and support multiple languages
  • Copy and paste this code at the value line in your selector window:

"value": ["text-first-language", "text-second-language", "etc."]

This code will do the following: If Userlane finds "text-first-language" OR "text-second-language" OR "etc." as text in the element, then the element will be found.

  • Change the placeholder texts to your different languages. 


How to check if the code selector works properly? 
  • If the element is found the Element status dot would be green.

  • If Userlane can not detect the selected element then the green Element status dot would turn orange. This means that the element is not visible now, which means that either: 
    1. the element is not there, or; 
    2. the element is not visible on the screen when the application loads and Userlane runs the element check.

Do you need more info?

If you have any questions, please reach out to us via our contact form.