$x("//div[@class='card-info__container']/div[3]/a")
using this I've found the container, but now I can't get the specific element I need.
when I enter this the response is:
⯆(3) [a.cta.btn, a.cta.btn, a.cta.btn]
⯈0: a.cta.btn
⯈1: a.cta.btn
⯈2: a.cta.btn
how can I take only the first one?
CodePudding user response:
You can use the at()
method to select the first item from the array of a
that is returned from executing the XPath:
$x("//div[@class='card-info__container']/div[3]/a").at(0)
CodePudding user response:
For an XPath that returns a list of elements,
xpath
you can select only the first element via indexing:
(xpath)[1]