我尝试了很多解决方案,但没有一个能为我工作。我有一个页面打开弹出窗口,当我尝试使用该弹出窗口执行任何操作时,它表示元素不可见。
根据情况,首先需要花费时间来加载数据,如下图所示Popup_1,然后它显示数据如下图所示Popup_2。
我试图把不关闭弹出窗口的条件设置为我得到文字“成功:”。
我的代码:
for (String handle : driver.getWindowHandles()) {
driver.switchTo().window(handle);}
WebDriverWait waitforEle = new WebDriverWait(driver, 300);
waitforEle.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//*[@id='divc8fff3cf6a']/div[1]/strong")));
driver.findElement(By.xpath("//*[@id='modal']/div[1]/a")).click();
弹出式HTML代码:
<div class="modal fade in" id="modal" style="display: block;"><div class="modal-header"><a class="close" href="#" data-dismiss="modal">×</a><h3>Delete Listings</h3></div><div class="inner"><div id="divc8fff3cf6a">
<div class="alert alert-success fade in">
<button class="close" data-dismiss="alert">×</button>
<strong>Success:</strong> 1 products have been queued for removal from Amazon.</div> <div class="modal-footer">
<a href="#" class="btn btn-small" onclick="location.reload()">Close</a> </div>
</div><script>
//<![CDATA[
window.customModal = {"formUUID":"#formfbe89bf4a5","modalUUID":"#divc8fff3cf6a"};
if(typeof window.customModal != 'undefined'){
$(window.customModal["formUUID"]).on("submit", function(e){
e.preventDefault();
$.ajax({
cache: false,
method: "POST",
data: $(this).serialize(),
url: $(this).attr("action"),
before: function(){
window.modal.close();
window.loading.show();
},
success: function(data, textStatus){
window.loading.close();
window.modal.options["content"] = data;
window.modal.show();
}
});
return false;
});
$(".resubmit").on("click", function(e){
window.modal.close();
$(window.app[$(this).data("resubmit")]).trigger("submit");
});
}
//]]>
</script></div></div>
答案 0 :(得分:0)
试试这个
if(alert.getText().contains("Success:"))
alert.dismiss();