Try-catch usually is:
try
command
command
command
catch
command you want to run if there is an error
end
I agree that this would be nice to have, but no Selenium IDE flavor has this yet. But with the UI.Vision RPA Selenium IDE, try/catch can be already be “simulated” with the two existing constructs:
- Internal variables: !errorignore and !statusOK
- OR: OnError command
The difference is that with the !statusOK solution all 3 “command” are executed, but with the OnError solution it “jumps” to the label on error => exactly as try/catch.
I usually use !statusOK more often, but that might be just because I am more used to it
Option 1: Use !statusOK
-
store | true | !errorignore
(do not stop macro on error) - command
- command
- command
If ${!statusOK} == true
- command you want to run if there is an error
end
-
store | false | !errorignore
(back to normal mode)
Option 2: Use OnError
OnError | #goto | mycatch
- command
- command
- command
GotoLabel | all_ok
- Label | mycatch
- command you want to run if there is an error
Label | all_ok
- …continue rest of macro here—
Screenshots:
!statusOK demo:
OnError demo: