How to finds links on a page and iterate through the list

I am using the kantu firefox plugin, and I want to find all links on a page with a specific class attribute then go to each link and grab the title from that page.

I am using:
{
“Command”: “storeAttribute”,
“Target”: “//div[@class=“happy-title”]/a@href”,
“Value”: “rowtext”
}
to store the link in a variable “rowtext”. I am not completely sure if this is the proper way to do this but it works. Now what I need is to find all links on the page that match class=“happy-title” and go to each page and extract the title from those pages.

Any help is appreciated.

I have tried: //div[@class=“happy-title”][1]/a@href, //div[@class=“happy-title”][2]/a@href, //div[@class=“happy-title”][3]/a@href, etc. but that did not work.

Looking to do the same, any ideas yet?

It is an old question, but as I stumbled upon the same problem, I will post my solution.

The problem with the above XPath expressions is to find the correct way to handle multiple elements. The index must not be within the XPath expression. You have to encase the expression with parenthesis and then use the index.

The following example works for me:

{
  "Command": "store",
  "Target": "1",
  "Value": "loopSuccess"
},
{
  "Command": "store",
  "Target": "1",
  "Value": "loopCount"
},
{
  "Command": "while_v2",
  "Target": "(${loopSuccess} > 0)",
  "Value": ""
},
{
  "Command": "storeText",
  "Target": **"xpath=(//div[@class=\"col1\"]/span)[${loopCount}]",**
  "Value": "rowValName"
},
{
  "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": "end",
  "Target": "",
  "Value": ""
}