Extracting hidden element text in Selenium Webdriver
<p>I want to fetch the text "There are 4 products in your cart" in Selenium Webdriver using Java.</p>

<pre><code>    &lt;h2&gt;
     &lt;!-- Plural Case [both cases are needed because page may be updated in Javascript] --&gt;
     &lt;span class="ajax_cart_product_txt_s unvisible" style="display: inline;"&gt;
        There are 
        &lt;span class="ajax_cart_quantity"&gt;4&lt;/span&gt;
        items in your cart.
     &lt;/span&gt;
     &lt;!-- Singular Case [both cases are needed because page may be updated in Javascript] --&gt;
     &lt;span class="ajax_cart_product_txt " style="display: none;"&gt; There is 1 item in your cart. &lt;/span&gt;
     &lt;/h2&gt;
</code></pre>

<p>I have tried using getText() and innerHTML but it hasn't worked.</p>