Timeout Reached When Looking for Element - with IF statement

I’ve set my !timeout_wait to 5 seconds. I randomly get a timeout reached error during a loop:

[error] [Line 39]: timeout reached when looking for element ‘x’

I am doing verifyElementPresent nested inside one another but I reset !statusOK before each verify command.

    {
          "Command": "store",
          "Target": "true",
          "Value": "!statusOK"
        },
        {
          "Command": "verifyElementPresent",
          "Target": "xpath=//div[contains(text(),\"Price history\")]",
          "Value": ""
        },
        {
          "Command": "if_v2",
          "Target": "${!statusOK} == true",
          "Value": ""
        },
        {
          "Command": "store",
          "Target": "true",
          "Value": "!statusOK"
        },
        {
          "Command": "verifyElementPresent",
          "Target": "xpath=//XYZ",
          "Value": ""
        },
        {
          "Command": "if_v2",
          "Target": "${!statusOK} == true",
          "Value": ""
        },
        {
          "Command": "click",
          "Target": "xpath=//XYZ",
          "Value": ""
        },
        {
          "Command": "end",
          "Target": "",
          "Value": ""
        },
        {
          "Command": "end",
          "Target": "",
          "Value": ""
        }

What is this xpath ? Seems wrong

        {
          "Command": "verifyElementPresent",
          "Target": "xpath=//XYZ",
          "Value": ""
        },

It is just a dummy xpath. What I thought happens with the logic is if element is found not to be present, then it returns !statusOK false and skips down to the next ELSE or END command. If it doesn’t find the element then it should return a false, not an error. I don’t know why a verifyelementpresent would ever return an error unless something is incorrect with the syntax of that line.

Also I’m unsure of exactly how the wait timeout works. I observe that if I have it at 10 seconds then the verifyelementpresent will wait all 10 seconds if it’s not there then move on to the next command. But if I have a page fully loaded, can I set the wait time to be something like 0.1 seconds? It’s either there or it’s not. I’ve tried 2 or 3 seconds and it’s worked ok

This part is wrong

        {
          "Command": "if_v2",
          "Target": "${!statusOK} == true",
          "Value": ""
        },
        {
          "Command": "store",
          "Target": "true",
          "Value": "!statusOK"
        },

If statusok is true you do not store true again (because it’s true verified by if_v2) i think you must add this after end of if_v2

I have another statusOK reset because I have another verifyelement present nested within the first one - and I want to reset statusOK to true before proceeding to the next verification

!Statusok is one and shared for all command have not sense this command

{
          "Command": "if_v2",
          "Target": "${!statusOK} == true",
          "Value": ""
        },
        {
          "Command": "store",
          "Target": "true",
          "Value": "!statusOK"
        },

Is wrong syntax, becase inside if it will store only when statusok is true, but what is the sense to store statusok true when statusok is true ?.

Your macro code is not well written and tidy so I can’t help you.

Ok, question: if you have an if statement and the result is false so !statusOK now = false, then if you want to do a subsequent if statement, don’t you have to reset the !statusOK to true before proceeding? Or do you just add one global variable !statusOK = true at the top and any following !statusOK = true lines are just superfluous?

I still don’t quite understand what you want to do but there are many different solutions.

For example I do not use the verifyElementPresent command but I use the simple click command, I verify it with !statusok and after I store a variable for the step (step1_ok), after I create a new if command and control the step_2 and so on.

I can check unilimitd steps in this mode

What’s the advantage of using Click instead of verifyElementPresent? Is click quicker to execute? Also I thought if verifyElementPresent is false it will still proceed with the macro but if a click fails because an element is not present, then the maco stops. So If I’m looping it many times then it will stop the whole macro