Programs starts to clog up radomly

My program is made to download PDF files from my website and it works, for a short duration, but after around 32 plus PDF files it stops saving them to my file explorer and I can’t figure out why that is. I the problem is around the Xtypes since it doesn’t rename the file and click enter.

My code:
{
“Name”: “PROGRAM”,
“CreationDate”: “2024-2-9”,
“Commands”: [
{
“Command”: “openBrowser”,
“Target”: “https://www.example.com/”,
“Value”: “”,
“Description”: “Change page link in Target”
},
{
“Command”: “waitForPageToLoad”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “4321”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “label”,
“Target”: “starterLoop”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “2”,
“Value”: “index”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return 3000 + Math.floor(Math.random()7500);",
“Value”: “mid”,
“Description”: “”
},
{
“Command”: “waitForPageToLoad”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: "xpath=//
[@id="Body_ResultsDiv"]/div/div[2]/div/a/b”,
“Value”: “prviText”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="Body_ResultsDiv"]/div/div[2]/div/a/b",
“Value”: “”,
“Targets”: [
"xpath=//
[@id="Body_ResultsDiv"]/div/div[2]/div”,
“xpath=//div[2]/div[2]/div/div[2]/div”,
“css=#Body_ResultsDiv > div:nth-child(1) > div.pull-left.metadata > div.Naslov”
],
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “1500”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “waitForPageToLoad”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${mid}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: “xpath=(//a[contains(text(),‘URN’)])”,
“Value”: “extractedText”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: “xpath=(//a[contains(text(),‘Klekl’)])”,
“Value”: “textAuthor”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “1000”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=(//a[contains(text(),‘PDF’)])”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${mid}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “XType”,
“Target”: “${firstText}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${mid}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “XType”,
“Target”: “${KEY_ENTER}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${mid}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “${firstText} - ${textAuthor} - ${extractedText}”,
“Value”: “!csvLine”,
“Description”: “”
},
{
“Command”: “csvSave”,
“Target”: “Data”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript”,
“Target”: “history.back();”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${mid}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “comment”,
“Target”: “----------------------------”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “label”,
“Target”: “startLoop”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return 2000 + Math.floor(Math.random()8000);",
“Value”: “p”,
“Description”: “”
},
{
“Command”: “waitForPageToLoad”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${p}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: "xpath=//
[@id="Body_ResultsDiv"]/div[${index}]/div[2]/div/a/b”,
“Value”: “ekstraktTekst”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//[@id="Body_ResultsDiv"]/div[${index}]/div[2]/div/a/b",
“Value”: “”,
“Targets”: [
"xpath=//
[@id="Body_ResultsDiv"]/div/div[2]/div”,
“xpath=//div[2]/div[2]/div/div[2]/div”,
“css=#Body_ResultsDiv > div:nth-child(1) > div.pull-left.metadata > div.Naslov”
],
“Description”: “”
},
{
“Command”: “waitForPageToLoad”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${p}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: “xpath=(//a[contains(text(),‘URN’)])”,
“Value”: “extractedText”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: “xpath=(//a[contains(text(),‘Klekl’)])”,
“Value”: “textAuthor”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “${extractText} - ${textAuthor} - ${extractedText}”,
“Value”: “!csvLine”,
“Description”: "textAuthor "
},
{
“Command”: “pause”,
“Target”: “${p}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “xpath=(//a[contains(text(),‘PDF’)])”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${p}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “XType”,
“Target”: “${extractText}”,
“Value”: “”,
“Description”: "_${extractedText} "
},
{
“Command”: “pause”,
“Target”: “${p}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “XType”,
“Target”: “${KEY_ENTER}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${p}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “${index}+1”,
“Value”: “index”,
“Description”: “”
},
{
“Command”: “csvSave”,
“Target”: “Data”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${p}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript”,
“Target”: “history.back();”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${p}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “echo”,
“Target”: “${index}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “if”,
“Target”: “${index} == ${EndOfPage}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return 1000 + Math.floor(Math.random()5000);",
“Value”: “next”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${next}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “id=Body_ctl01_NextLink”,
“Value”: “”,
“Targets”: [
“id=Body_ctl01_NextLink”,
“name=ctl00$Body$ctl01$NextLink”,
"xpath=//
[@id="Body_ctl01_NextLink"]”,
“xpath=//input[@id=‘Body_ctl01_NextLink’]”,
“xpath=//div/div/input[3]”,
“css=#Body_ctl01_NextLink”
],
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “3000”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “waitForPageToLoad”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${next}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “gotoIf”,
“Target”: “true”,
“Value”: “starterLoop”,
“Description”: “”
},
{
“Command”: “else”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “gotoIf”,
“Target”: “true”,
“Value”: “startLoop”,
“Description”: “”
},
{
“Command”: “pause”,
“Target”: “${next}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
}
]
}

Do you have a test macro for us? We can not run this (your) macro here.

Hi, I’m new to this, how can I give you a test macro?