The Invoke action allows you to act on a repository item without any direct interaction like mouse clicks or keyboard input. This is particularly useful for manipulating UI elements that aren’t visible, such as windows that are out of focus or list items to which you need to scroll.
In this chapter, learn how to use the Invoke action through two examples.
Simple button click
In this example, perform a simple button click with an Invoke action. Action 1 in the image below performs a mouse click to the Add entry button of the AUT.
To replace it with an Invoke action that does the same:
-
Click Add new action > Invoke action.
-
An empty Invoke action appears in the actions table.
-
From the repository, drag the item BtnAddPerson that represents the Add entry button to the Invoke action.
-
In the Action name column of the Invoke action, select PerformClick().
- Finally, right-click the regular Mouse click action and click Disable to disable it.
Result(s):
The click on the Add entry button is now executed directly without any mouse interaction.
List item selection
Automating list item selection can be challenging because often, certain items won’t immediately be visible. Using an Invoke action instead of a regular mouse interaction can often make your test more robust. The image below shows a standard list item selection using Mouse click actions.
-
Mouse click action that opens the Department drop-down.
-
Mouse click action that selects Project Management from the list items.
To perform this with an Invoke action instead:
-
Click Add action > Invoke action twice to add two empty Invoke actions.
-
From the repository, drag the item Open representing the drop-down button to the first Invoke action. Repeat for the second Invoke action with the item ProjectManagement representing the Project Management list item.
-
In the Action name column of the first Invoke action, select Press (). Repeat for the second Invoke action with Select ().
-
Finally, right-click the regular Mouse click actions and click Disable to disable them.
Result(s):
The list item selection is now executed directly without any mouse interaction.