title: Get Text with Selenium Webdriver in Java
body: <p>I need to extract text Paul Robert this html and print to the console using the Java WebDriver and selenium .</p>
  
  <p>The code below extracts all text Div , even the text " Quit".</p>
  
  <pre><code>&lt;div role="alert" class="alert success" id="control_gen_3"&gt;
   &lt;p&gt;
   &lt;strong&gt;Invite to &lt;a href=""&gt;Paul Robert&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;
   &lt;button class="dismiss" id="global-error-dismiss"&gt;Quit&lt;/button&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>Code Selenium:</p>
  
  <pre><code>String pessoa = driver.findElement(By.id("control_gen_3")).getText();               
  System.out.println(pessoa );
  </code></pre>