While loop only works one time

When trying to do a while loop it seems to work great the first time, but if the macro plays more then one time in a row the second time it runs it fails and never runs the while loop.

</ {

“Name”: “aatr_company”,
“CreationDate”: “2018-12-7”,
“Commands”: [
{
“Command”: “type”,
“Target”: “//[@id="object-table-__multiple"]/table[2]/thead/tr/th[1]/input",
“Value”: “on”
},
{
“Command”: “click”,
“Target”: "//
[@id="object-table-__multiple"]/table[2]/thead/tr/th[1]/input”,
“Value”: “”
},
{
“Command”: “click”,
“Target”: “id=edit-object-list-mass-update-update-field”,
“Value”: “”
},
{
“Command”: “select”,
“Target”: “id=edit-object-list-mass-update-update-field”,
“Value”: “label=Company”
},
{
“Command”: “click”,
“Target”: “id=edit-object-list-mass-update-update”,
“Value”: “”
},
{
“Command”: “click”,
“Target”: “id=edit-company-und-0-value-text”,
“Value”: “”
},
{
“Command”: “select”,
“Target”: “id=edit-company-und-0-value-text”,
“Value”: “label=AATR ORLANDO”
},
{
“Command”: “click”,
“Target”: “id=edit-submit”,
“Value”: “”
},
{
“Command”: “pause”,
“Target”: “3000”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “true”,
“Value”: “!errorignore”
},
{
“Command”: “while”,
“Target”: “${!statusOK}”,
“Value”: “”
},
{
“Command”: “waitForVisible”,
“Target”: “id=updateprogress”,
“Value”: “”
},
{
“Command”: “endWhile”,
“Target”: “”,
“Value”: “”
}
]
} >

“Command”: “while”,
“Target”: “${!statusOK}”

What is the value of {!statusOK}? Maybe it is false and that is why the loops stops?

You don’t need a while loop for “waitForVisible” - it kind of has its own build-in while loop and waits for the element to appear. If needed, you can increase the wait time with !timeout_wait.

I would disagree Timo. I’ve an instance where I’ve done a file upload, am waiting for the file upload to “register”. I use waitForVisible to see if the “card” (status line) appears, but within the status line is the actual statue (loading or available). WaitForVisible waits but fails, at which point the screen is refreshed by Kantu, and then loops for WaitForVisible again because after the refresh, it might change from loading to available. If I only used WaitForVisible, it would never work because of the website. The only problem is, there’s a bug which means, once the first waitForVisible fails, it doesn’t matter if the element it’s waiting for then appears, it just keeps failing repeatedly.

Instead of the HTML-based waitForVisible, you can also use the visual XClick (image) to wait for “things” to appear or change or disappear on a website.