verifyElementPresent not updating !statusOk

Hi,

I have a macro that loads 3 pages on my website and runs another macro that checks for 404 page content, it works on the first page but when the next page is loaded, which I’m loading a page that doesnt exist on purpose, when the 404 macro is ran again the verifyElementPresent doesn’t switch !statusOk to True.

Main Macro that loads the home page, runs 404 check, then loads the 404 page that then checks 404 on that page:

{
  "Name": "homepage_index",
  "CreationDate": "2021-5-13",
  "Commands": [
    {
      "Command": "run",
      "Target": "/Sagegoddess/environment",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "open",
      "Target": "${env}.${url}/",
      "Value": "",
      "Description": "Test Home Page"
    },
    {
      "Command": "run",
      "Target": "/Sagegoddess/pages/site_structure/404_check",
      "Value": "404 Check",
      "Description": "404 Check"
    },
    {
      "Command": "run",
      "Target": "/Sagegoddess/pages/library_blog",
      "Value": "",
      "Description": ""
    }
  ]
}

This macro is the 404 check logic:

{
  "Name": "404_check",
  "CreationDate": "2021-5-13",
  "Commands": [
    {
      "Command": "store",
      "Target": "3",
      "Value": "!timeout_wait",
      "Description": ""
    },
    {
      "Command": "verifyElementPresent",
      "Target": "xpath=//*[@class=\"page-title\"]",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "if_v2",
      "Target": "${!statusOk} == true",
      "Value": "If page-title exists, possibly 404",
      "Description": ""
    },
    {
      "Command": "verifyText",
      "Target": "xpath=//*[@class=\"page-title\"]",
      "Value": "Oops! That page can’t be found.",
      "Description": ""
    },
    {
      "Command": "if_v2",
      "Target": "${!statusOk}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "throwError",
      "Target": "Page does not exist",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "END",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "END",
      "Description": ""
    }
  ]
}

when the 404 macro is ran again the verifyElementPresent doesn’t switch !statusOk to True.

See Statusok not changing value - #5 by ulrich

1 Like

Thank you @ulrich went with !lastcommandOK as it’s predictable and less conditionals.