Skip to main content

         This documentation site is for previous versions. Visit our new documentation site for current releases.      

Robotic Automation example: Handling cancelable events in .NET

Updated on September 10, 2021

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.

Handling cancellable events example

To test this solution, complete the following steps:

  1. Download and run the attached solution in Robot Studio.
  2. Go to the Bing search page and then enter text into the Search field.
  3. Click Search.
Note: This exercise works both for the Bing search home page and for the search results page. There are many ways to do this, but this example uses a separate control for each page, as shown in the preceding example.

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:

Match rule properties

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 versionBuilt using versionDownload Event Example 8.0
8.0 SP18.0.2037Cancel Event Example 8.0 SP1 Event Example 19.1
  • Previous topic Robotic Automation example: Correcting the DataGridView Red X error
  • Next topic Robotic Automation example: Integrating a ListView within an application


Robotics System Architect Robotic Process Automation

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us