Get xpath of a child using its parent

Viewed 22

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.

1 Answers

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
Related