Thanks again for your great help.
In order to work for me, in “If End” block and in “Do repeatIf” block I needed to change the condition to ${!statusOK} == true.
Additionally, I got this error using “ClickAndWait” and needed to change to simple “Click” and add a Pause of 5 seconds but I think is not a best practice.
Below my current code
[error]
Line 6: Error #200: 'clickAndWait' failed. No page load event detected after 10 seconds. Try 'click' instead. Error details: Error #220: Still same ipc secret(more info)
{
"Name": "LoginWithRetriesDoRepeatIf",
"CreationDate": "2024-3-3",
"Commands": [
{
"Command": "store",
"Target": "0",
"Value": "loginAttempts",
"Description": ""
},
{
"Command": "do",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "open",
"Target": "https://myexample.com",
"Value": "",
"Description": ""
},
{
"Command": "type",
"Target": "id=username",
"Value": "yourUsername"
},
{
"Command": "type",
"Target": "id=password",
"Value": "yourPassword"
},
{
"Command": "click",
"Target": "xpath=//button[@type='submit']",
"Value": "",
"Description": ""
},
{
"Command": "pause",
"Target": "5000",
"Value": "",
"Description": ""
},
{
"Command": "store",
"Target": "true",
"Value": "!statusOK",
"Description": ""
},
{
"Command": "verifyElementPresent",
"Target": "css=.error",
"Value": "",
"Description": ""
},
{
"Command": "if",
"Target": "${!statusOK} == true",
"Value": "",
"Description": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "return Number(${loginAttempts}) + 1;",
"Value": "loginAttempts",
"Description": ""
},
{
"Command": "echo",
"Target": "Login attempt ${loginAttempts} failed, trying again...",
"Value": "red",
"Description": ""
},
{
"Command": "end",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "repeatIf",
"Target": "${loginAttempts} < 3 && ${!statusOK} == true",
"Value": "",
"Description": ""
},
{
"Command": "comment",
"Target": "Continue with the rest of the script after successful login or all attempts fail",
"Value": "",
"Description": ""
},
{
"Command": "if",
"Target": "${!statusOK} == true",
"Value": "",
"Description": ""
},
{
"Command": "throwError",
"Target": "Login failed after 3 attempts.,
"Value": "",
"Description": ""
},
{
"Command": "else",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "echo",
"Target": "Login successful!",
"Value": "green",
"Description": ""
},
{
"Command": "end",
"Target": "",
"Value": "",
"Description": ""
},
{
"Command": "comment",
"Target": "Continue script",
"Value": "",
"Description": ""
}
]
}