I’m trying to loop through and store all the tracking number text fields on a page (about 100 on a page). Each id is unique so I can’t iterate through something like loopCount + 1. Here’s the element:
<a href="https://www.website.com/ship/tr/Events?itemid=234472029152&transid=1989887018" class="trackingOverlay">9405508205497426618222</a>
I want to save “9405508205497426618222” to csv. It is always to the right of the class ‘trackingOverlay’
I tried something like sourceExtract xPath=//*[trackingOverlay">*</a]@{!loopCount}
and that would iterate through all the matches on the page until exhausted. But that didn’t work I kept getting “#nomatchfound”
Here’s my code:
`{
"Name": "tracking number scraper",
"CreationDate": "2020-10-16",
"Commands": [
{
"Command": "bringBrowserToForeground",
"Target": "",
"Value": ""
},
{
"Command": "comment",
"Target": "open // https://www.website.com/sh/ord/?filter=status:ALL_ORDERS",
"Value": ""
},
{
"Command": "store",
"Target": "1",
"Value": "loopSuccess"
},
{
"Command": "store",
"Target": "1",
"Value": "loopCount"
},
{
"Command": "while_v2",
"Target": "${loopSuccess} > 0",
"Value": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[contains(@class,'trackingOverlay')]",
"Value": "!csvLine"
},
{
"Command": "if_v2",
"Target": "!${!statusOK}",
"Value": ""
},
{
"Command": "store",
"Target": "0",
"Value": "loopSuccess"
},
{
"Command": "end",
"Target": "",
"Value": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "return Number(${loopCount}) + 1;",
"Value": "loopCount"
},
{
"Command": "csvSave",
"Target": "eBayTrackingNumbers",
"Value": ""
},
{
"Command": "end",
"Target": "",
"Value": ""
}
]
}`
This loops through and saves to the csv file fine, but it only saves the first text over and over. It doesn’t iterate through the different elements. I also tried these two lines instead of the storeText line but couldnt’ get it to work
`{
"Command": "comment",
"Target": "sourceExtract // \"trackingOverlay\">*</a>@{!numberCount}",
"Value": "trackingNumber"
},
{
"Command": "comment",
"Target": "store // {!trackingNumber}",
"Value": "!csvLine"
},`