Categories
Mastering Development

selecting div with multiple non-nested specific children

<div class="outer">
    <div>
        <span>Some text</span>
    </div>
    <div>
        <span class="className">information that I don't know</span>
    </div>
</div>
<div class="outer">
    <div>
        <span>Some different text</span>
    </div>
    <div>
        <span class="className">information that I don't know</span>
    </div>
</div>

If I have multiple divs with same class and I want to select specific <span> inside that div I would do it like this:

//div[contains(@class,'outer')]/descendant::span[contains(text(),'Some text')]

this will select <span>Some text</span> from first div.

How do I select span with text and class className with text information that I don't know from first div? something like:

//div[contains(@class,'outer')]/descendant::span[contains(text(),'Some text')] and /descendant::span[contains(@class,'className')]

Leave a Reply

Your email address will not be published. Required fields are marked *