I want to get the sub parent element <div class="post"/>
given the text of a post in this case given the text "post2" that is the second div in the code
there are many posts in a page.
I tried to use an xpath like this that I did thinking that is possible find between in the sub-parents web elements: "//div[@id='content']//span[contains(text(), 'post2')]/.//*[@class='post']"
<div id="content">
<div class="post">
<div class="right">
<div class="content">
<div class="post-content">
<span>
post1
</span>
</div>
</div>
</div>
</div>
<div class="post">
<div class="right">
<div class="content">
<div class="post-content">
<span>
post2
</span>
</div>
</div>
</div>
</div>
</div>
exists any other solution for that or maybe the xpath is wrong?