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