VerifyElementPresent Bug

It seems VerifyElementPresent is not working as advertised. From the documentation:

The difference is that verify command will verify the condition and if it does not match, it will only show an error message in log area and the macro continues to run.

However, it throws an error and stops running:

info]
Executing: | verifyElementPresent | link=ENTER ANYWAY | |
[error]
timeout reached when looking for element ‘link=ENTER ANYWAY’
[info]
Macro failed (Runtime 49.41s)

In this case, the page is waiting for audio input, and after a few seconds will display buttons based on the result. ENTER ANYWAY is one possibility. If it doesn’t exist, I want the algorithm to continue.

1 Like

I can not recreate this bug. I made a small test case with a non-existing element, and the macro continues just fine.

Macro:

{
  "CreationDate": "2018-7-7",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://a9t9.com/",
      "Value": ""
    },
    {
      "Command": "verifyElementPresent",
      "Target": "//*[@id=\"xxxxxxxxxlogo\"]/img",
      "Value": ""
    },
    {
      "Command": "clickAndWait",
      "Target": "//*[@id=\"logo\"]/img",
      "Value": ""
    }
  ]
}

Log (note that the error is ignored:“… [error][ignored]”):

...
Executing:  | verifyElementPresent | //*[@id="xxxxxxxxxlogo"]/img |  | 
[error][ignored]
'//*[@id="xxxxxxxxxlogo"]/img' element not present
[info]
Executing:  | clickAndWait | //*[@id="logo"]/img |  | 
[info]
Macro completed (Runtime 13.42s)

=> Can you send me a test case where the macro stops?

In general if you want to avoid that a macro stops because of an error, you can set the
!errorignore internal variable to true (and back to false once the sequence of commands where you want to ignore errors is over):

  • store true !errorignore
  • command(s) to ignore error…
  • store false !errorignore

Thank you for your reply. I cannot give you access to the page because it is a private member area, but here is the algorithm:

{
  "Command": "while",
  "Target": "2>1",
  "Value": ""
},
{
  "Command": "verifyElementPresent",
  "Target": "link=ENTER ANYWAY",
  "Value": ""
},
{
  "Command": "gotoIf",
  "Target": "${!LastCommandOK}",
  "Value": "EnterAnyway"
},
{
  "Command": "click",
  "Target": "link=Re-check",
  "Value": "WaitForButton"
},
{
  "Command": "endWhile",
  "Target": "",
  "Value": ""
},

It’s an infinite loop that that breaks when the ENTER ANYWAY link appears, and keeps clicking “Re-check” in the meantime.

I think that setting !errorignore shouldn’t be necessary, because verifyElementPresent should continue if the element isn’t found.

Totally agree! And this is how it works in my test macro above (macro continues). => Can you create the issue with verifyElementPresent on a (similar?) public page? Then we can debut the issue and fix it.

Okay, I simply merged your example into mine, and the error persists:

{
“CreationDate”: “2018-7-9”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://a9t9.com/”,
“Value”: “”
},
{
“Command”: “while”,
“Target”: “2>1”,
“Value”: “”
},
{
“Command”: “verifyElementPresent”,
“Target”: “//*[@id="xxxxxxxxxlogo"]/img”,
“Value”: “”
},
{
“Command”: “gotoIf”,
“Target”: “${!LastCommandOK}”,
“Value”: “EnterAnyway”
},
{
“Command”: “click”,
“Target”: “link=Web Testing”,
“Value”: “”
},
{
“Command”: “endWhile”,
“Target”: “”,
“Value”: “”
},
{
“Command”: “label”,
“Target”: “EnterAnyway”,
“Value”: “”
}
]
}

When run:

[status]
Playing macro Test
[info]
Executing: | open | https://a9t9.com/ | |
[info]
Executing: | while | 2>1 | |
[info]
Executing: | verifyElementPresent | //[@id=“xxxxxxxxxlogo”]/img | |
[error]
timeout reached when looking for element '//
[@id=“xxxxxxxxxlogo”]/img’
[info]
Macro failed (Runtime 48.52s)

I hope this helps.

Did you ever get back to this?

I just tested your macro - and it works just fine :thinking: => I tested in Chrome and Firefox, just to be sure. Below is a screenshot. Very strange… now I have no idea why it would not work for you. If you have any additional ideas or test cases, please let me know.

Well then, I don’t have a clue, either. I am using version 3.12 on Chrome installed on Windows 10. The OS and Chrome are up to date.

I have the same issue, it doesn’t work at all.

Yep, same issue here. Same code format. Nothing as far as what could be causing it?

I have the same exact problem. I created a script and it worked awesome for a while, ran through the loop a couple hundred times. Now I can’t get it to run at all. Everytime it hits the verifyElementPresent it times out and then errors and the script stops. It doesn’t even get to the next line to check if the lastcommandok it stops where before it would continue and say error ignored in the log… this seems broken… can’t get it to work anymore…

I was able to bypass this problem and get the script to continue working by setting the variable !errorignore to false first as mentioned earlier in this thread using the store command. It’s a pain in the ass though but it’s working now.

unrelated to this problem I had other bugs where the script worked fine for many times in the loop but then would fail randomly on different steps. I found that one issue is the clickandwait command is not reliable and works sometimes but fails frequently. One thing to get the script to run more reliably is to switch to the click command and include a manual pause… kind of lame it’s not reliable. Another issue with the waitforpagetoload command. not reliable and fails sometimes, randomly. switch to a manual pause and hope the page loads in time is more reliable. also tweaking the command max execution time to 20 or 30 seconds can help…

i guess this thing isn’t perfect but there are some work arounds…

yes same problem here. I searched the problem and found this forum post. at least I know it’s not me doing something wrong.

  • [info]

Executing: | verifyElementPresent | id=dns | |

  • [error]

timeout reached when looking for element ‘id=dns’

I am having a similar issue, seemingly at random. Most of the time, the check works just fine, but every now and then when it fails to find the element, it goes to the next line (an if checking to see if LASTCOMMANDOK is true) and times out.

Fixed with V5.0 (if not, please re-open)

I do have the same exact issue. I’m using brave browser.

Just ran into the same bug and I’m on v5.2.3. If it helps I was using the element id=login in which it would throw an error and stop running. When I switched the element to text, it works as expected.

@admin @TechSupport am also getting this same issue. The script is getting failed at verifyElementPresent step if the element is not present. Could you please provide any solution for this as this is show stopper now for most people like me and our test suites are unable to run.

For those that still see the issue, can you please post a test macro?

@admin Please find the script below -

{
“Command”: “open”,
“Target”: “website link”,
“Value”: “”
}
{
“Name”: “sub_Check_TomTom_Login”,
“CreationDate”: “2019-12-12”,
“Commands”: [
{
“Command”: “verifyElementPresent”,
“Target”: “id=IDToken1”,
“Value”: “”
},
{
“Command”: “if_v2”,
“Target”: “${!LastCommandOK}”,
“Value”: “”
},
{
“Command”: “click”,
“Target”: “id=IDToken1”,
“Value”: “”
},
{
“Command”: “type”,
“Target”: “id=IDToken1”,
“Value”: "msr.preprod@tomtom.com"
},
{
“Command”: “click”,
“Target”: “id=IDToken2”,
“Value”: “”
},
{
“Command”: “type”,
“Target”: “id=IDToken2”,
“Value”: “tomtom123”
},
{
“Command”: “click”,
“Target”: “id=loginButton”,
“Value”: “”
},
{
“Command”: “waitForPageToLoad”,
“Target”: “”,
“Value”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”
}
]
}

@admin
To followup this is still occurring. I’m now on v5.3.8 using Chrome. I can run a macro back to back with no changes and it will ignore like it’s supposed to one time and not the next. You can clearly see sometimes it works like assert:

1 Like