In Selenium Webdriver, how to get a text after an element? <p>I would like to get a text that exactly comes after a specific element. Pleases look the sample code:</p> <pre><code>&lt;div id="content-tab-submitter" class=""&gt; &lt;h4&gt;Sender&lt;/h4&gt; &lt;p&gt; &lt;span class="screenHidden"&gt;Name: &lt;/span&gt; submitter &lt;br&gt; &lt;span class="screenHidden"&gt;E-mail address:&lt;/span&gt; submitter@asd.com &lt;br&gt; &lt;span class="screenHidden"&gt;Account: &lt;/span&gt; asdas &lt;br&gt; &lt;/p&gt; &lt;/div&gt; </code></pre> <p>I would like to get the text that comes exactly after <code>&lt;span&gt;</code> which contains "Account". By using this xpath:</p> <pre><code>//*[@id='content-tab-submitter']/p/span[contains(text(),'Account')]/following::text() </code></pre> <p>JAVA gives me an error, since the output is not a web element and it is a text. So, it is not possible to use findElement. Is there any idea how to get this text in a clean way. I mean I do not want to get all texts: (in this case) submitter\nsubmitter@asd.com\nasdas and then extract the desired text.</p> <p>Many thanks in advance for your valuable comments!</p>