'While' is not working to use a loop for scraping a table

I have followed these steps to collect data in a particular column for each row: Incrementing each loop - #3 by ulrich

Here is my use of it.

However it says there is an error in for the ‘while’ section. I can’t see ‘While_V2’ when i go to type in a command. Is this the problem?

Cheers

I’ve realised i hadn’t put the ‘end’ part it. Now it runs, but its not inputting numbers where I’ve entered {i} in the xpath where I want the row number to change. Here is the JSON:

{
“Command”: “store”,
“Target”: “fast”,
“Value”: “!replayspeed”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “i”,
“Description”: “”
},
{
“Command”: “while”,
“Target”: “${i} < 122”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return Number (${i}) + 1;”,
“Value”: “i”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: “xpath=//*[@id="partnerList"]/table/tbody/tr[{i}]/td[4]”,
“Value”: “Region{i}”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “${Region{i}}”,
“Value”: “!csvLine”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},

Your macro code seems wrong i do not see the csvname where save the data after store with csvsave

This is wrong ${Region{i}}

Must be Region${i}

You can creare grabber with TIMES is more simple to use and need not While or executeScript_Sandbox to increase counter

1 Like

${i} is stored as a string if you use “store” command. That could impact your while loop.
Instead I would you an execute to create an integer variable:

{
“Command”: “executeScript”,
“Target”: “return 1;”,
“Value”: “i”,
“Description”: “”
},

1 Like