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

Need help locating element with XPath

I am learning about xpath , can you help me go to the "i class" tag and click on reddit’s up vote icon. I tried to find the comment text

I can connect the paragraph

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

//div[contains(p/text(),'The user name completes this')]

and find the up vote icon tag right below this comment

https://www.reddit.com/r/me_irl/comments/zg7nr5/comment/izgy4a3/?utm_source=reddit&utm_medium=web2x&context=3

>Solution :

You can locate the parent div block of the entire comment by the text content and then go to upvote button inside it as following:

"//div[contains(.,'The user name completes this')][contains(@class,'Comment')]//button[@aria-label='upvote']"

I’m not sure you really need that i icon element so I gave the locator of the upvote button.
In case you really need the i element inside it – it can be located similarly as following

"//div[contains(.,'The user name completes this')][contains(@class,'Comment')]//i[contains(@class,'upvote')]"
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