将Webdriver与C#一起使用
我正在尝试使用findelement关闭模式弹出窗口。不确定使用哪个findelement来关闭模态。
// HTML
<div id="simplemodal-container" class="simplemodal-container" style="background-color: rgb(255, 255, 255); border-color: rgb(255, 255, 255); height: 297px; padding: 0px; width: 984px; position: fixed; z-index: 1002; left: 138.5px; top: 75.5px;">
<a class="modalCloseImg simplemodal-close" title="Close"></a>
<div class="simplemodal-wrap" tabindex="-1" style="height: 100%; outline: 0px none; width: 100%; overflow: visible;">
<div id="simplemodal-data" class="simplemodal-data" style="">
<div class="modal_info tariff_T010129">
<img class="table_image" width="974" height="287" longdesc="http://www.three.ie/products_services/priceplans/billpay/index.html" alt="Flexifix tariff info" src="https://www.three.ie/imgs/shop/tariff_info/flexifix-tariff-table.jpg" style="">
</div>
</div>
</div>
</div>
X按钮的CSS
#simplemodal-container a.modalCloseImg {
background: url("../Content/Images/x.png") no-repeat; top: -15px; width: 25px; height: 29px; right: -18px; display: inline; position: absolute; z-index: 3200; cursor: pointer;
}
答案 0 :(得分:0)
也许是最简单的方法,因为你已经发现这个元素的相关CSS
会使用它。
driver.findElement(By.cssSelector("a.modalCloseImg")).click();
(那是Java
,但我相信你可以修改C#
。)