XPath is not finding element <p>XPath I created: </p> <pre class="lang-none prettyprint-override"><code>.//*[@id='stepCongrats']/div[2]/div[3]/div[2]/ul/li[1]/span </code></pre> <p>using this xPath I am getting message: NoSuchElementException</p> <p>Below is my html code: </p> <pre><code>&lt;div id="stepCongrats"&gt; &lt;div id="ancillary-congratulations"&gt;&lt;/div&gt; &lt;div id="elephant"&gt;&lt;/div&gt; &lt;div class="sect"&gt; &lt;div class="s-header"&gt;&lt;/div&gt; &lt;div class="s-nav"&gt;&lt;/div&gt; &lt;div class="s-body"&gt; &lt;div class="s-policyholder"&gt;&lt;/div&gt; &lt;div class="s-policyinfo"&gt; &lt;ul&gt; &lt;li&gt; &lt;h6&gt; Policy number &lt;/h6&gt; &lt;span&gt; 247-000-001-13 &lt;/span&gt; </code></pre>