Here is a solution:
-
the macro searches the table for a row with a certain text in the first column (note the
${myrow}
variable inside the xpath}, in this line: storeText | /html/body/div[4]/div[1]/div[2]/div[2]/table/tbody/tr[${myrow}]/td[1]" -
it extracts text with storeText into a variable, and runs in a loop until the text is found :
gotoIf ${text2search}"!="${rowtext}"
-
then uses the number of the found row to click the right link (“Download@POS=${myrow}”)
ADMIN note 2020/10/18: This example still uses GotoIf (deprecated). With the new GotoIf_V2 the syntax is slightly different: See gotoIf - Error in condition of gotoIf_v2: Invalid or unexpected token - #2 by admin
Macro:
{
"CreationDate": "2018-6-18",
"Commands": [
{
"Command": "open",
"Target": "https://www.sample-videos.com/download-sample-sql.php",
"Value": ""
},
{
"Command": "store",
"Target": "fast",
"Value": "!replayspeed"
},
{
"Command": "store",
"Target": "500,000",
"Value": "text2search"
},
{
"Command": "store",
"Target": "0",
"Value": "myrow"
},
{
"Command": "label",
"Target": "searchrow_loop",
"Value": ""
},
{
"Command": "storeEval",
"Target": "${myrow}+1",
"Value": "myrow"
},
{
"Command": "storeText",
"Target": "/html/body/div[4]/div[1]/div[2]/div[2]/table/tbody/tr[${myrow}]/td[1]",
"Value": "rowtext"
},
{
"Command": "echo",
"Target": "Text from Row=${rowtext}",
"Value": ""
},
{
"Command": "echo",
"Target": "text2search=${text2search} / rowtext=${rowtext}",
"Value": ""
},
{
"Command": "gotoIf",
"Target": "\"${text2search}\"!=\"${rowtext}\"",
"Value": "searchrow_loop"
},
{
"Command": "echo",
"Target": "myrow=${myrow}",
"Value": ""
},
{
"Command": "comment",
"Target": "Row found, click link!",
"Value": ""
},
{
"Command": "click",
"Target": "link=Click@POS=${myrow}",
"Value": ""
}
]
}