从HTML下面:
<div class="wpsc_buy_button_container group">
<br>
<div class="input-button-buy">
<br>
<span><input type="submit" value="Add To Cart" name="Buy" class="wpsc_buy_button"></span>
<br>
<div class="alert error">
<br>
<p>Please select product options before adding to cart</p>
<br>
<span> </span>
<br>
</div>
点击“添加到购物车”按钮后,将显示警告错误并将被隐藏。 如何捕获<div>
警报addtocart,因为默认情况下会隐藏它?
<div>
<br>
<div class="alert addtocart" style="display: none;">
<br>
<p>Item has been added to your cart!</p>
<br>
<span> </span>
<br>
</div>
<!--close input-button-buy-->
<div class="wpsc_loading_animation" style="visibility: hidden;">
<br>
<img title="Loading" alt="Loading" src="http://store.demoqa.com/wp-content/themes/mio/images/ajax-loader.gif">
</div>
<!--close wpsc_loading_animation-->
<br>
</div>
答案 0 :(得分:0)
尝试使用JavascriptExecutor
使用此代码:
WebElement element_hide= driver.findElement(By.xpath("wpsc_loading_animation");
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element_hide);