title: getText() in WebDriver using Java
body: <p>The following is the HTML code:</p>
  
  <pre><code>&lt;div id="TITLE" class="text"&gt;
  &lt;label for="widget_polarisCommunityInput_113_title"&gt;Title&lt;/label&gt;
  &lt;input type="text" name="field(TITLE)" id="widget_polarisCommunityInput_113_title"&gt;
  &lt;div class="error"&gt;This field must not be empty&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I tried to get the text "This field must not be empty" as follows by using WebDriver with Java:</p>
  
  <pre><code>driver.findElement(By.xpath("//div[@id='TITLE']/div")).getText();
  driver.findElement(By.xpath("//div[@class='error']")).getText();
  </code></pre>
  
  <p>But, no text was retrieved. How can I do it? What's the wrong with my code?</p>
  
  <p>Yes, there is a form. HTMl code including form as belows:</p>
  
  <pre><code>&lt;form action="http://community.sandbox.no/content/save.do;jsessionid=F2BF733599D8D9F812B89ACBC20D37C5" method="post"&gt;
  &lt;div id="widget_polarisCommunityInput_113_leftcolumn"&gt;
  &lt;input type="hidden" value="article" name="articleType"&gt;
  &lt;input type="hidden" value="published" name="state"&gt;
  &lt;input type="hidden" value=" " name="successUrl"&gt;
  &lt;input type="hidden" value="" name="articleId"&gt;
  &lt;input type="hidden" value="http://sandbox.no/community/article/" name="redirect_url"&gt;
  &lt;input type="hidden" value="113" name="widget_id"&gt;
  &lt;div id="TITLE" class="text"&gt;
  &lt;label for="widget_polarisCommunityInput_113_title"&gt;Title&lt;/label&gt;
  &lt;input type="text" name="field(TITLE)" id="widget_polarisCommunityInput_113_title"&gt;
  &lt;div class="error"&gt;This field must not be empty&lt;/div&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>