title: How to extract the text of the outer span using Selenium WebDriver and Java
body: <p>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:</p>
  
  <pre><code>&lt;span class="abc"&gt;
          &lt;span class="def"&gt;Inner Span&lt;/span&gt; 
          Outer Span
  &lt;/span&gt;
  </code></pre>
  
  <p>When I'm using </p>
  
  <pre><code>driver.findElement(By.cssSelector(".abc")).getText()
  </code></pre>
  
  <p>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".</p>