0

I want to fetch the text "There are 4 products in your cart" in Selenium Webdriver using Java.

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

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

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66

1 Answers1

0

Can you try below if it helps:

String text = "return $('.ajax_cart_product_txt_s.unvisible').text();";
Abhinav
  • 1,037
  • 6
  • 20
  • 43