Identify controls by image: Image-Based Test Automation

The Identify by Image functionality doesn't support accessibility features. If you require accessibility features, consider other methods to identify your controls.

Tosca can identify controls from an image by pairing a specific control with one or more specific screenshots.

Identify a control by image

To identify a control by image follow these steps: 

  1. Scan your system under test with Tosca XScan and open its Advanced View.

  2. Select the control you want to identify in the tree view of the scan. Then, select ADVANCED IDENTIFICATION > IMAGE in the Identification methods pane.

  3. In the Identifying Images pane, select the add image icon.

  4. Use your mouse to capture a screenshot of the identifier in your application.

  5. Optionally, configure the Search Properties for this particular identifier:

    Search property

    Description

    Accuracy

    Define how closely (in percent) an identifier must match its screenshot during the test run. The lower the value, the less closely they must match.

    Method

    Define where Tosca should look for the identifier during test runs:

    • Fullscreen: always search the entire screen.

    • Controlbased: only search the vicinity of the control.

    • Auto: leave the decision up to Tosca.

  6. Make sure your identifier is visible on your screen, so that Tosca XScan can run its uniqueness check on it.

  7. If you need to identify multiple controls by image for the same module, try to have all identifiers visible on the screen for the uniqueness check. if that's not possible let Tosca XScan run the uniqueness check on each control individually.

You can create the module regardless of the outcome of the uniqueness check. Note that if an identifier isn't unique, Tosca XScan won't reliably find it during test runs.

Considerations

When it comes to identifying controls by image, keep these things in mind:

  • The state of your implementation. How much change do you still expect in your application? If there are major design changes after the scan, Tosca will have trouble finding a match for the screenshot.

  • The screen resolution, color depth, or scrolling. Make sure that the user who scans the application has the same settings as the machine that runs your tests.

  • The number of screenshots you need to reliably identify a control. Controls don't always look the same. For example, you might have text boxes with changing content or toggle buttons with a different look in ON and OFF mode. Use more than one screenshot per control. For example, add a screenshot of an input field's label, or take screenshots of a toggle button in ON and in OFF mode.

  • The test execution time. At runtime, Tosca searches for a match for the first screenshot. If Tosca can't find a match, it moves on to the next screenshot, then the next, and so on. In other words, each additional screenshot increases test execution time. Limit the number of screenshots per control to what's absolutely necessary for identification.

What's next

Identification by image not working for what you need? No problem—try properties, index, or anchor.