How to download all files on a page

Hi, I am trying to write a script that downloads all uploaded files from a user’s portfolio page on an education platform. Each user account may have a different number of files to download. All the downloads can be located by a CSS element and I’ve tried to create a script that loops through the page so that it will download each file until it executes the final download.

However it just repeatedly downloads the first file, so my question is how do I get it move onto the next file?

I’m afraid I cannot share a public URL.

I’ve removed the code that loops through a csv file to retrieve the user-id as I got that working fine, it’s the downloads within the page I cannot get working,. Any help appreciated :slight_smile:

{
“Name”: “05 Download Notes files-1”,
“CreationDate”: “2022-12-14”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://www.xxxxxxxxx.co.uk/portfolio/portfolio.aspx?UserID=xxxxxxxxx”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “loopSuccess”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “loopCount”,
“Description”: “”
},
{
“Command”: “while_v2”,
“Target”: “(${loopSuccess} > 0)”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “click”,
“Target”: “fieldset > a > div.attachment-download”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “if_v2”,
“Target”: “!${!statusOK}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “0”,
“Value”: “loopSuccess”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return Number(${loopCount}) + 1;”,
“Value”: “loopCount”,
“Description”: “”
},
{
“Command”: “echo”,
“Target”: “Loop count: ${loopCount}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
}
]
}

It will only download 1st file.

use xpath to locate all the files

Thanks @uiuser

For the record (and for anyone searching in future), the Target statement that worked was “xpath=(/descendant:: fieldset/a/div[@class=“attachment-download”])[${loopCount}]”

try

(//div[@class=“attachment-download”])[${loopCount}]