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:
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:
-
Create a Test Case
Create a new test case, for example, named
Template
. -
Assign Tags
Right-click the test case while holding Shift; then select Tags.
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.
-
Learn an Object
Start the recorder and learn a UI object:
After recording, press Finish.
-
Rename Objects (Optional)
-
Rename the learned object to something meaningful, such as
Button
. -
You may also rename the containing window.
-
-
Tag the Repository
-
Switch to the Test Files view.
-
Select the
Objects.js
file next to theMain
file. -
In the Properties panel, set the
Tags
field totemplate
.
-
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:
The user right-clicks on TestCases/CreateInvoice and chooses Add Repository Object.
You will be prompted to provide a 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:
The new object appears within the same window:
Adding Next to Another Object¶
Right-click on an existing repository object and choose Add Repository 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:
When you use Add Repository Object, a selection dialog will appear:
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 thetemplate
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
andtemplate
ensures clean integration with dashboards and test sets.