Auto-Selector Strategies

The recording process requires that SnapTest auto-generates a unique way to "select" an element. There are many strategies out there for using the most resilient selectors, and many of them are excellent. The two most notable ones are using an "id" exclusively and/or using a "test-id" attribute. Unfortunately, not all testers have access to add testing specific code, and will need other ways to get a handle on an element.

SnapTest lets you choose the selector strategies you need from the following list:

  1. attribute (by default "test-id")- Checks for the specified attribute.
  2. id - Checks the element for an id.
  3. name - Checks the element for an "name" attribute.
  4. node type - Checks the element for its type.
  5. ancestor - Attempts to select an element based upon class name and common ancestor.
  6. class - Cycles through the class names, and finds any that are unique.

SnapTest will walk down this list looking for a unique selector. Re-order or toggle any of the strategies for your application needs via the settings menu:

Group 6Record it…Play it…Generate it…GeneratorsSelector AlgorithmsPrivate modeTest organizationTeamsWorkspacesDedicated supportTest data storageDebugger toolsAdaptable TestsCLI tools and APIWhite-labeled codeVariablesMulti-test playbackManual testsComponents