Throw Exception

Verb: failTest

Available from: <Enterprise>

Throws an exception in the script, returning a message about that exception in the Test Viewer of IBM RPA Studio.

Syntax

failTest --message(String)

Inputs

Script Designer Required AcceptedTypes Description
--message Message Required Text Message recorded when the exception is thrown.
The IBM RPA Studio environment variable "errorMessage" is fed with the value entered in Message.

Example

Example 1: The command raises an exception due to the website being accessed in English. The error message is: "This script cannot be executed, the page is in Portuguese."

defVar --name siteEN --type String --value "https://www.ibm.com"
webStart --name web01 --type "Chrome"
webNavigate --url "${siteEN}"
if --left "${siteEN}" --operator "Contains" --right "lang=en" --negate
	failTest --message "This script cannot be executed, the page is in Portuguese."
else
	messageBox --title "Welcome!" --text "Welcome to the IBM Robotic Process Automation website!\r\n" --icon "Information" --buttons "OK" --defaultbutton "FirstButton"
endIf
webClose --name web01 --leavebrowseropen

Example 2: Similar to the previous one, however, using a page in English, to demonstrate the scenario of success in the execution of the script.

defVar --name siteEN --type String --value "https://www.ibm.com"
webStart --name web01 --type "Chrome"
webNavigate --url "${siteEN}"
if --left "${siteEN}" --operator "Contains" --right "lang=en" --negate
   failTest --message "This script cannot be executed, the page is in Portuguese."
else
   messageBox --title "Welcome!" --text "Welcome to the IBM Robotic Process Automation website!\r\n" --icon "Information" --buttons "OK" --defaultbutton "FirstButton"
endIf
webClose --name web01 --leavebrowseropen

The validation of the exception scenarios is visualized through the Test Viewer of IBM RPA Studio. In the case of both examples presented, the validation returns as "Failed".

Remarks

The Throw Exception command will not efficiently catch the exception, if it is outside the IBM RPA Studio Testing context. Because of that, this command will not be used during process automation.

The IBM RPA Studio Test Viewer is available in the top menu, under the path: View> Tests Explorer.

The exception raised by Throw Exception can be caught by the Handle Error command.

See Also

  • Assert Condition
  • Expected Exception
  • Parser Expected Exception
  • Test Case