Errors in logic processing for assertElementPresent

Im using Brave Version 1.62.162 Chromium: 121.0.6167.164 (Official Build) (64-bit) with UI RPA 9.0.1, to periodically open a web page, checking if an element (button) is present, then clicking a button if it is there. I’ve removed the while and other looping and just given the meat here:

{
  "Command": "store",
  "Target": "true",
  "Value": "!ERRORIGNORE",
  "Description": ""
},
{
  "Command": "store",
  "Target": "15",
  "Value": "!TIMEOUT_PAGELOAD",
  "Description": ""
},
{
  "Command": "open",
  "Target": "https://REDACTED",
  "Value": "",
  "Description": ""
},    {
  "Command": "store",
  "Target": "true",
  "Value": "!STATUSOK",
  "Description": ""
},
{
  "Command": "store",
  "Target": "5",
  "Value": "!TIMEOUT_WAIT",
  "Description": ""
},
{
  "Command": "assertElementPresent",
  "Target": "id=otp-send",
  "Value": "",
  "Description": ""
},
{
  "Command": "if_v2",
  "Target": "${!STATUSOK} == true",
  "Value": "",
  "Description": ""
},
{
  "Command": "click",
  "Target": "id=otp-send",
  "Value": "",
  "Description": ""
},

It works well over half the time, but frequently it bombs, where this is what should normally happen if the button isnt present:

* [info] Executing: | assertElementPresent | id=otp-send | |

* [error][ignored] [Line 7](chrome-extension://gcbalfbdmfieckjlnblleoemohcganoc/popup.html#): timeout reached when looking for element 'id=otp-send'

I have it set up like that so as to be able to proceed with my RPA. But sometimes that if_v2 statement does return true even though the button is not actually there, then the whole thing bombs when it tries to click the button thats not there. I’ve checked the page source, sure enough that element is not present. So not sure why that if_v2 results in the wrong condition.

Besides that though, I suppose there probably is a better setup to repeatedly open a page up and checking if the button is there and clicking on it, and if not then waiting 30secs and redoing the whole thing. If so maybe I can work around this?

Hello, your macro looks fine on a first glance. Since this is about an internal page https://REDACTED I can not test what goes wrong.

Possible workaround: Another good option to check for the presence of a button/page element would be to do this visually with visualAssert | imageOfbutton.png - can you try this?

Unfortunately theres not any image on the page Im trying to go to that isnt also present on any of the other pages that I may be redirect to in the event the server decides to send me elsewhere. I used to check the URL that ended up being present after the page loaded, but UIVision bombed on that occasionally and I could never figure out why, so I moved to the id=“” mechanism. The only thing I can seem to reliably check for is the id field of the button

I am telling you now though, that in every case that when this thing just barfs itself, theres simply not any element in the DOM with the id of otp-send. I have no idea why the if statement is passing.

Inversely - the same thing also happens in a different step when checking for an email login box:

{
  "Command": "assertElementPresent",
  "Target": "id=login-email",
  "Value": "",
  "Description": ""
},
{
  "Command": "if",
  "Target": "${!STATUSOK} == true",
  "Value": "",
  "Description": ""
},
{
  "Command": "run",
  "Target": "login",
  "Value": "",
  "Description": ""
},

When using the pause/step function, the variable for !STATUSOK in the variables tab is reporting a false, even though in the source of the page there is clearly an id=“login-email” there.

Again, this issue is intermittend, itll run fine for a few hours, periodically the server logs the RPA out and it detects this and logs back in just fine, until at some point the logic just fails and reports that !statusok as false even though the element is clearly in the source. The page is even loading very quickly and so theres no timeout issue here.

Bizarre. Surely I cant be the same person seeing this… it even does it on different browsers.

Could it be that you did not reset !StatusOK?

Before using !statusOK for a new test you should do

store | true | !statusOK

Reason is, commands like assertElementPresent or CLICK or any other command never set the !statusOK to true. All they to is to set it to false if an error happened. But once !statusOK is false, it stays false until you explicitly reset it with store | true | !statusOK.

ugh ok im sure thats it. I was not aware of the reset requirement.
ugh.

but THANKS