How to work with SubSelectors

Subselectors help you make your element targeting more precise. They’re useful when a simple selector (like a button or label) is not unique enough, and you want to anchor it more reliably inside a container.


When to use a subSelector

  • When the same label or text appears multiple times on a page.

  • When the main element is too broad (e.g., a big container or an iframe).

  • When you need to anchor an element inside another element (like a label inside a form).

  • When no page segmentation is possible you can base the selector on a unique text on the page (for Tooltips, Tags or Validators).


Step-by-step instructions

We are guiding you through an example on how to write the subSelector.

  1. Launch the Userlane Editor for the page you’re working on.

  2. Select the bigger which includes both elements and anchor it with element text by clicking Add Element Text (like ‘Willkommen bei Wikipedia’). Change “contains” to “matches” if a certain appears multiple times.

Input A: 

  1. Copy the selector that was generated for this big element (you’ll need it soon).

  2. Click Cancel to exit that selection.

  3. Click on Reselect Element

  4. Select the label or smaller element you want and again anchor it with its text (like ‘Kunst und Kultur’ by clicking Add Element Text . Change “contains” to “matches” if a certain appears multiple times.

Input B:

  1. Copy the 1st selector you had from the big element before this 

  2. Keep just one selector as the main anchor (IFRAME#myframe) and add the second selector as a subSelector (make sure writing is correct)

  3. Simplify the Selector: 
    Trim it to the essentials: keep just the label or a specific DIV with a concrete, stable ID. Remove anything extra (long ancestor chains, unrelated classes, headings, etc.).
    If your selector shows “score” bits, remove them.

  1. Check brackets and punctuation
     Make sure every ( has a ), every [ has a ], and quotes are paired. If the Syntax is correct, Apply Changes can be clicked.


Click on the image for a bigger version of our example:


Best practices

Contains vs Matches

  • Contains → looks for part of the text

  • Matches → looks for an exact text match

  • If wording appears multiple times, use Matches.

Selector hygiene

  • Copy–paste text from the UI to avoid typos.

  • Remove unnecessary “heaviness” (long paths or unrelated divs).

  • Prefer unique attributes like IDs. The Editor is going to display if an element is unique.

  • Always test in the actual page state before finalizing.

Common pitfalls

  • Forgetting to switch to Matches when there are duplicates.

  • Extra spaces or hidden line breaks breaking the match.

  • Leaving in long, fragile paths instead of simplifying to the stable part.

  • Missing or unbalanced brackets.


User Icon

Thank you! Your comment has been submitted for approval.

// load Userlane (function(i,s,o,g,r,a,m){i['UserlaneCommandObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)};a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://cdn.userlane.com/userlane.js','Userlane'); // initialize Userlane Userlane('init', 'xn08mq76gk');