我想使用Java在Selenium Webdriver中获取文本“购物车中有4个产品”。
<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>
我尝试过使用getText()和innerHTML,但它没有用。
答案 0 :(得分:0)
如果有帮助,你可以尝试下面的内容:
String text = "return $('.ajax_cart_product_txt_s.unvisible').text();";