title: Why is getText() in Selenium not working for <textarea> elements, but getAttribute("value") is?
body: <p>Given you have some HTML with a textarea element and want to get its text via Selenium (here Java-binding).</p>
  <pre><code>&lt;textarea name=&quot;txtComment&quot; id=&quot;txtComment&quot; rows=&quot;2&quot; cols=&quot;20&quot;&gt;
      Some comment inside the textarea
  &lt;/textarea&gt;
  </code></pre>
  <br>
  <p>This is how I see the code via developer tools (Internet Explorer and Firefox), so it seems like it is a normal text-node and not inside the &quot;value&quot; attribute of the element.</p>
  <p>Why is it then that <strong>getText() does not work</strong>:</p>
  <pre><code>driver.findElement(By.id(&quot;txtComment&quot;)).getText();
  </code></pre>
  <p>It only <em>returns an empty String</em>.</p>
  <p><em>But</em> using <strong>getAttribute(&quot;value&quot;) works</strong> and results in returning the expected string:</p>
  <pre><code>driver.findElement(By.id(&quot;txtComment&quot;)).getAttribute(&quot;value&quot;);
  </code></pre>
  <p>This <em>returns &quot;Some comment inside the textarea&quot; as expected</em></p>
  <p>This is rather surprising since the Selenium documentation about <a href="https://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html#getText%28%29" rel="nofollow noreferrer">getText()</a> says the following:</p>
  <blockquote>
  <p>Get the visible (i.e. not hidden by CSS) innerText of this element,
  including sub-elements, without any leading or trailing whitespace.</p>
  <p>Returns:
  The innerText of this element.</p>
  </blockquote>
  <p>As the HTML code in the beginning shows, the text-part of the element is visible and it is the &quot;innerText&quot;, isn't it?</p>
  <h3>Can someone shed light on where I'm wrong or if I'm not, why is this implemented like this in Selenium?</h3>