This is a good question. So I created a short demo macro. Here I used while/endWhile, but if you use the !loop feature (like in the solution above) this is not needed.
The key part to read from an array is:
Create array and assign to a variable:
{
“Command”: “storeEval”,
“Target”: “new Array (‘A’,‘B’,‘C’,‘D’,‘E’)”,
“Value”: “names”
},
Access a value of the array with storedVars:
{
"Command": "storeEval",
"Target": "storedVars['names'][${num}]",
"Value": "letter"
},
Complete demo macro (screencast of it here):
The macro takes a screenshot of each page (just to do something), but of course you can replace or enhance this part this with the web scraping code from above.
{
"CreationDate": "2018-7-8",
"Commands": [
{
"Command": "open",
"Target": "https://www.xe.com/ibancalculator/countrylist/",
"Value": ""
},
{
"Command": "store",
"Target": "fast",
"Value": "!replayspeed"
},
{
"Command": "comment",
"Target": "Fill array and calculate its length",
"Value": "!replayspeed"
},
{
"Command": "storeEval",
"Target": "new Array ('A','B','C','D','E')",
"Value": "names"
},
{
"Command": "storeEval",
"Target": "storedVars['names'].length",
"Value": "length"
},
{
"Command": "echo",
"Target": "array length = ${length}",
"Value": "pink"
},
{
"Command": "comment",
"Target": "Arrays start with 0 (not 1)",
"Value": "num"
},
{
"Command": "store",
"Target": "0",
"Value": "num"
},
{
"Command": "while",
"Target": "${num} < ${length}",
"Value": "num"
},
{
"Command": "storeEval",
"Target": "storedVars['names'][${num}]",
"Value": "letter"
},
{
"Command": "echo",
"Target": "letter=${letter}",
"Value": "blue"
},
{
"Command": "click",
"Target": "link=${letter}",
"Value": ""
},
{
"Command": "captureScreenshot",
"Target": "page_${letter}",
"Value": ""
},
{
"Command": "storeEval",
"Target": "${num}+1",
"Value": "num"
},
{
"Command": "endWhile",
"Target": "",
"Value": ""
},
{
"Command": "echo",
"Target": "done with ${num} while loops",
"Value": "green"
}
]
}