Expected Exception
Verb: expectedException
Available from: <Enterprise>
Validates exception scenarios in a script, approving or disapproving those scenarios, through the IBM RPA Studio's Test Explorer.
Syntax
expectedException --exception(String) --message(String)
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--exception | Exception | Required | Text | Text referring to the exception expected during the execution of a script. Some types of exceptions expected are:
For more types, visit Exception Class.NET. |
--message | Message | Required | Text | Registered text if the expected exception does not occur. |
Example
The Click command tries to click on a Notepad element that has the "ID" value equal to "Name"; as it does not find this element, a mapped error named "RuntimeException" occurs on IBM RPA Studio. The message is displayed in the test explorer as "Approved", as the error was as expected.
defVar --name window --type Window
expectedException --exception RuntimeException --message "not find"
launchWindow --executablepath "notepad.exe" window=value
focusWindow --window ${window}
click --selector "Id" --controlsimilarity 100 --id Name --timeout 00:00:01
// After following the instructions, the test is expected to produce the following result:
// expectedException.wal
// [APPROVED] ExpectedException
1. The validation of the exception scenarios is visualized through the "Tests Explorer" of IBM RPA Studio.
2. To use the IBM RPA Studio "Tests Explorer", you must first save the sample script and then go to the top menu, on the path:*View > Tests Explorer > Collapse all items > Select the folder in which the script was saved to > All scripts from the folder and sub folders will be listed > Right-click on the saved example script > Run Selected Tests*.
Remarks
The Expected Exception command will not efficiently catch the exception if it is outside the IBM Robotic Process Automation Tester. This command will not be used during process automation.