VerifyElementPresent Bug


#1

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.


#2

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

#3

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.


#4

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.


#5

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.


#7

Did you ever get back to this?


#8

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.


#9

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.


#10

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


#11

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