Hi all,
I designed the following to find something on a page in 3 different ways and write the link to csv if found. I originally tried if-elseIf-else-end and couldn’t wrap my head around it. I continued to read and came up with this solution using gotoIf. My impression is that the code below is overly complicated and a similar effect could’ve been achieved more easily. I would love your expertise on how you would’ve approached this. Thank you!
{
"Name": "scrape-3",
"CreationDate": "2020-6-28",
"Commands": [
{
"Command": "csvRead",
"Target": "website.csv",
"Value": ""
},
{
"Command": "open",
"Target": "${!COL1}",
"Value": ""
},
{
"Command": "verifyElementPresent",
"Target": "partialLinktext=donat",
"Value": ""
},
{
"Command": "gotoIf_v2",
"Target": "${!LASTCOMMANDOK}",
"Value": "donsave"
},
{
"Command": "verifyElementPresent",
"Target": "partialLinktext=contrib",
"Value": ""
},
{
"Command": "gotoIf_v2",
"Target": "${!LASTCOMMANDOK}",
"Value": "consave"
},
{
"Command": "verifyElementPresent",
"Target": "xpath=//*[contains(@href,'donat')]",
"Value": ""
},
{
"Command": "gotoIf_v2",
"Target": "${!LASTCOMMANDOK}",
"Value": "linksave"
},
{
"Command": "store",
"Target": "notautofound",
"Value": "!csvline"
},
{
"Command": "gotoLabel",
"Target": "csvSave",
"Value": ""
},
{
"Command": "label",
"Target": "linksave",
"Value": ""
},
{
"Command": "storeAttribute",
"Target": "xpath=//*[contains(@href,'donat')]@href",
"Value": "!csvline"
},
{
"Command": "gotoLabel",
"Target": "csvSave",
"Value": ""
},
{
"Command": "label",
"Target": "consave",
"Value": ""
},
{
"Command": "storeAttribute",
"Target": "partialLinktext=contrib@href",
"Value": "!csvline"
},
{
"Command": "gotoLabel",
"Target": "csvSave",
"Value": ""
},
{
"Command": "label",
"Target": "donsave",
"Value": ""
},
{
"Command": "storeAttribute",
"Target": "partialLinktext=donat@href",
"Value": "!csvline"
},
{
"Command": "gotoLabel",
"Target": "csvSave",
"Value": ""
},
{
"Command": "label",
"Target": "csvSave",
"Value": ""
},
{
"Command": "label",
"Target": "csvSave",
"Value": ""
},
{
"Command": "store",
"Target": "${!COL1}",
"Value": "!csvline"
},
{
"Command": "csvSave",
"Target": "donatelink",
"Value": ""
}
]
}