how can I use this command $x("//div[@class='card-info__container']/div[3]/a").at(0)
in selenium for finding the element I need.
I know that I can use findElement(By.xpath())
using this //div[@class='card-info__container']/div[3]/a
but what should I do with the at()
function?
CodePudding user response:
.at(0)
is not a part of XPath expression here and you can not use it with Selenium.
In the expression you showing in your question the $x
is applied on the "//div[@class='card-info__container']/div[3]/a"
Xpath expression and then .at(0)
is applied on the result of the previous action.
UPD
So, in order to locate the first "Download Datasheet" button you can use this XPath locator:
(//div[@class='card-info__container']/div[3]/a)[1]
To access the second button you can use
(//div[@class='card-info__container']/div[3]/a)[2]
etc.