Skip to content

Object Templates

Purpose

The Object Templates feature allows you to model test cases using placeholder repository objects before you learn them from the application. This is useful when designing Modules / Page Objects prior to actual implementation.

Object Templates are only available when working in Testing Framework mode.

How to Use

Right-click on a Test Case, Page Object / Module, or Object Repository Window in the Object Tree. The Add Repository Object option will appear.

This command inserts a repository object copied from a predefined template object.

One-Time Setup: Creating a Template

Before you can use object templates, you must create at least one template object.

If no template is defined, you will see an error like this:

Missing Template

Error Adding Object from Template

You need to have a template object.

I was unable to find an Objects.js repository marked with the template tag.

Create a Module or a Test Case with a single object, and mark its Objects.js with the template tag to use this feature.

Follow these steps to define a template:

  1. Create a Test Case

    Create a new test case, for example, named Template.

    Create Test Case Test Case Name - Template

  2. Assign Tags

    Right-click the test case while holding Shift; then select Tags.

    Assign Tags - Draft & Skip

    Add the following tags:

    • template – Marks the test case and its repository as a template.
    • skip – Optional; prevents the test from being executed or displayed in Spira Dashboard.

    Test Case with Template Tag

  3. Learn an Object

    Start the recorder and learn a UI object:

    Start Recording Learn a Button Object

    After recording, press Finish.

  4. Rename Objects (Optional)

    • Rename the learned object to something meaningful, such as Button.

      Rename Rename to Button

    • You may also rename the containing window.

      Where to Rename a Window

  5. Tag the Repository

    • Switch to the Test Files view.

      Show in Test Files Tree

    • Select the Objects.js file next to the Main file.

    • In the Properties panel, set the Tags field to template.

      Template Object.js Tags Template Object.js set template Tags

Adding Repository Objects from Template

Once the template is defined, you can add repository objects from it to other test cases or page objects.

Adding to a Test Case or Module

Right-click on a test case or module in the Object Tree and choose the Add Repository Object option:

Add Repository Object

The user right-clicks on TestCases/CreateInvoice and chooses Add Repository Object.

You will be prompted to provide a new object ID:

Enter New Object Id

The new object appears in the Object Tree under the window from the template. You can rename it as needed.

Adding to a Window

Right-click on a window node in the Object Tree and choose Add Repository Object:

Add New Object into Existing Repository Window

The new object appears within the same window:

Object In the Window

Adding Next to Another Object

Right-click on an existing repository object and choose Add Repository Object:

Add New Object next to Existing Object

The new object will be added to the same window.

💡 You can also clone an object to achieve a similar result.

Multiple Template Objects

You can define multiple objects within a single template repository. For example, you may define both a Button and TextBox object:

Two Objects in the Template

When you use Add Repository Object, a selection dialog will appear:

Choose an Object to Add

Select the object you want to insert and click OK.

Summary

  • Object Templates allow for designing tests before actual object learning.
  • You must first create a test case or module and mark its Objects.js with the template tag.
  • Use Add Repository Object from the Object Tree to insert template-based objects.
  • Supports insertion into test cases, page objects, object windows, or alongside other objects.
  • Multiple template objects can be defined, and users will be prompted to select one when adding.
  • Tagging test cases with skip and template ensures clean integration with dashboards and test sets.