Robotic Automation example: Handling cancelable events in .NET
Some events, such as button clicking, are passed to the automation code before the application gets the event. These events are named with the -ing suffix, such as Clicking and RightClicking. You handle all of these events and then, optionally, pass them to the application. If you choose not to pass an event to the application, the event is cancelled.
Cancelable events receive the CancelEventArgs argument, which has the Cancel property. To prevent an event from being passed to the application, set the Cancel property to True and then handle the event as needed in your automation.
In the attached solution, the homePageBox text field object is associated with the Search field on the Bing search page. The searchResultsBox text field object is associated with the Search field on the Bing search results page. If the text in the Bing Search field matches the text in the equals block, the system cancels the search.
To test this solution, complete the following steps:
- Download and run the attached solution in Robot Studio.
- Go to the Bing search page and then enter text into the Search field.
- Click .
The Document Title match rule for the home page matches any webpage with “Bing” in the title. To uniquely identify the Bing search page, use the Document URL match rule. The following example shows the properties for this match rule:
The Path field contains a regex expression, \bsearch\b. The match rule criteria shown in this example identifies URLs that contain “search” as the correct URL for the search page.
|Pega Robot Studio version||Built using version||Download|
|8.0||8.0.1084||Cancel Event Example 8.0|
|8.0 SP1||8.0.2037||Cancel Event Example 8.0 SP1|
|19.1||188.8.131.52||Cancel Event Example 19.1|