Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97756

How to extract the text of the outer span only?

$
0
0

I'm facing a problem, where I'm unable to get the text of a span tag that has another span tag as a child:

<span class="abc">
        <span class="def">Inner Span</span> 
        Outer Span
</span>

When I'm using

driver.findElement(By.cssSelector(".abc")).getText()

Selenium returns "Inner Span" as well as "Outer Span". I guess innerText is used here. But I only need the text "Outer Span" of the outer span with the class "abc".


Viewing all articles
Browse latest Browse all 97756

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>