The Invoke action allows you to act on a repository item without any simulated UI interaction, such as 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 that require scrolling.
In this article, learn how to use the Invoke action through two examples.
Simple button click
In this example, you perform a simple button click with an Invoke action. Action 1 in the image below performs a mouse click on the Add entry button of the AUT.
To replace it with an Invoke action that does the same:
- In the actions table, 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. This links the action to the repository item.
-
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
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 some items are not immediately visible. Using an Invoke action instead of a regular mouse interaction can 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
The list item selection is now executed directly without any mouse interaction.