Henrique Amaral
Henrique Amaral

Reputation: 85

How to get a div that have another div with a specific text inside with XPATH on python3?

How can I get get the 'Text One' text with an XPATH that say: 'Get the div that has a span with text ='Type1' or 'Get the div that has a span with class ='class2' ?

<div>

    <div class='Row'>
        <span class='class1'>'Type1'</span> 
        <span>'Text One'</span>
    </div>

    <div class='Row'>
        <span class='class2'>'Type2'</span> 
        <span>'Text Two'</span>
    </div>

</div>

EDIT: And in that case what should I do?

<div>

    <div class='Row'>
        <div>
            <span class='class1'>Type1</span> 
        </div>
        <span>Text One</span>
    </div>

    <div class='Row'>
        <div>
            <span class='class1'>Type1</span>
        </div>
        <span>Text Two</span>
    </div>

</div>

I still want to get 'Text One' or 'Text 2'

Upvotes: 0

Views: 58

Answers (1)

supputuri
supputuri

Reputation: 14135

Try with

//span[.="'Type1'"]/following-sibling::span

enter image description here

Upvotes: 1

Related Questions