Is there a way to take a screenshot of the current interface when an element is not found?

Is there a way to take a screenshot of the current interface when an element is not found?

Yes. In your code check the status of ${!statusOK} (true / false).

Example:

Code:

{
  "Name": "take screenshot on error",
  "CreationDate": "2024-1-10",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://ui.vision/rpa/home/welcome?t=hello",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "!statusOK",
      "Description": ""
    },
    {
      "Command": "verifyElementPresent",
      "Target": "xpath=//*[@id=\"start\"]/div/p/spanXXXXX",
      "Value": "",
      "Description": "I added XXXXX to trigger error for test"
    },
    {
      "Command": "if",
      "Target": "${!statusOK} == false",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "Error found!",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "captureScreenshot",
      "Target": "error1.png",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }
  ]
}