Is there any way to create recovery scenario for test case macro?

Hi,

I have bunch of test cases which are running one after other in test suite. I need to click on logout irrespective of the fact that whether test case pass or fail. because if application does not get logged out due to test case failure then it automatically fails all remaining test cases due to login issue.

Is there any way in Kantu to create the recovery scenario so that atleast logout will be get performed even any assertion gets failed during test case execution ?

See OnError | #goto | logout-label

It makes the macro jump to “logout-label” if an error happens. You find an example in the DemoIfElse macro.

Here is another test macro for OnError.

If an error happens inside the Label/GotoLabel loop, the macro jumps to the “restart_loop” label, and the loop is repeated. So if an error happens for i=123, the loop is re-run with with i=123 until it succeeds. Only when all commands worked ok we reach the last line of the loop (executeScript_Sandbox…) and the value of i is incremented.

{
  "Name": "RepeatLoop",
  "CreationDate": "2019-6-19",
  "Commands": [
    {
      "Command": "onError",
      "Target": "#goto",
      "Value": "restart_loop"
    },
    {
      "Command": "store",
      "Target": "fast",
      "Value": "!replayspeed"
    },
    {
      "Command": "store",
      "Target": "15",
      "Value": "!TIMEOUT_WAIT"
    },
    {
      "Command": "store",
      "Target": "60",
      "Value": "!TIMEOUT_PAGELOAD"
    },
    {
      "Command": "store",
      "Target": "1",
      "Value": "i"
    },
    {
      "Command": "label",
      "Target": "restart_loop",
      "Value": ""
    },
    {
      "Command": "if_v2",
      "Target": "${!statusOK} == false",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "ERROR!!! => restart from top, loop=${i}, status=${!statusOK}",
      "Value": "blue"
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "!statusOK"
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "label",
      "Target": "start",
      "Value": ""
    },
    {
      "Command": "open",
      "Target": "https://docs.google.com/forms/d/e/1FAIpQLScP-K8zi-9ar0MCq93D3VIFhegSNPveBfdLqiMfTYR9Q1iSKQ/viewform",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "//span[contains(text(),\"UI.Vision IDE\")]",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "//*[text()[contains(.,'Web Testing')]]",
      "Value": ""
    },
    {
      "Command": "clickAndWait",
      "Target": "css=span.quantumWizButtonPaperbuttonLabel.exportLabel",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "name=entry.1572386418",
      "Value": "this is loop ${i}"
    },
    {
      "Command": "clickAndWait",
      "Target": "//*[@id=\"mG61Hd\"]/div/div[2]/div[3]/div[1]/div[1]/div[2]/div[2]",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "done with ${i}",
      "Value": "green"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return Number (${i}) +  Number(1)",
      "Value": "i"
    },
    {
      "Command": "gotoLabel",
      "Target": "start",
      "Value": ""
    }
  ]
}
1 Like