Comparing stored variables

So, how do you compare two stored variables to confirm they match? In the old Selenium IDE, I would use verifyEval | storedVars.var1==storedVars.var2 | true. But it looks like verifyEval no longer exists?

I’m pulling a set of values from a csv and then storing values in web forms to be able to verify that the values in the web page match the variables stored from the csv. In some cases, I can simply verifyValue = ${variable}, but in others, such as dates, which are actually split across three fields, I have store the values then concatenate into a variable to compare to the variable from the csv.

You can use the if command plus ThrowError instead:

if  | !(storedVars['var1']==storedVars['var2'])
 ThrowError | "Variables do not match"
EndIf

These 3 lines are a direct and more flexible replacement for verifyEval.

Note that instead of

if | !(storedVars['var1']==storedVars['var2'])
Important: The solution here is for the deprecated first version of If (not if_v2). V2 no longer needs and supports storedVars.

This should also work:

if | !("${var1}" == ${var2}")
Important: If_V2 no longer uses “” around the variables. So now the answer is:
if | !(${var1} == ${var2})

1 Like

I also would use something like that:
storeEval | ${var1} == ${var2} | GLOBAL_EQUAL

I have two variables which depending on the outcome of previous steps in the macro, each variable COULD be either “Found,” or “Not Found.” The variables are called “SAMCheck” and “OIGCheck”

I have attached the section of code where I am trying to achieve this

{
      "Command": "if_v2",
      "Target": "!(\"${OIGCHECK}\" == ${SAMCHECK}\")",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "Clear No Results Returned",
      "Value": "!csvline"
    },
    {
      "Command": "store",
      "Target": "Clear No Results Returned",
      "Value": "Assess"
    },
    {
      "Command": "else",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "store",
      "Target": "Assess",
      "Value": "!csvline"
    },
    {
      "Command": "store",
      "Target": "Assess",
      "Value": "Assess"
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    },

This also seems to be a round about way of doing it – what I really want to do is see if BOTH – OIGCHECK & SAMCHECK = NOT FOUND and based on the result being either true or false save a new value to a new variable called “Assess,” which is either “Assess” or “ Clear No Results Returned”

Thank you!

Also sent to support email as an enterprise bundle user - not sure if support@a9t9 is correct or not for enterprise tickets

The syntax used by if_v2 is standard Javascript syntax. => I updated the answer above.

what I really want to do is see if BOTH – OIGCHECK & SAMCHECK = NOT FOUND

This should work:

If | (${OIGCHECK} == "NOT FOUND") && (${SAMCHECK} == "NOT FOUND")

1 Like

Thank you! I ended up figuring out that the above worked in IF_V1 - I will try the modified answer for If_V2 tomorrow - thank you very much for your quick response!