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

Get xpath of a child using its parent

This is the html code I got:

<i>
    "Updated at: "
    <span id="contact">2021-11-08 13:41 </span> 
    " / ( "
    <a href="https://www.google.com">Google</a>
    ")"
</i>

I want to get the xpath of the "a" element, using the id of the span above it. I know it should go something like this:

//span[@id='contact']...

But don’t know the rest.

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 :

The a element is not a child but is a next sibling of the span element here.
This should work in this case:

//span[@id='contact']/following-sibling::a
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