Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to use an xpath that use to() function in selenium

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

.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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading