[英]Java - Selenium WebDriver - How do I check if the File Download Dialog Box is visible? (Not download Only visibility)
是否可以使用Selenium WebDriver或任何其他Java庫檢查IE中的“文件下載”對話框是否可見?
我不想下載文件。 我無法驗證對話框的可見性。
另外,我無法關閉對話框。
有什么幫助嗎?
嘗試{
//Click the link that brings up the download dilaog
// Perform your next step : This is where the script will throw the excpetion due to the modal dialog.
}
catch(Exception e){
if(e.getMessage().contains("Modal dialog present")) {
System.out.println("A modal dialog is present. (which can be a download dialog)" );
System.out.println(e.getMessage());
// the exception message includes text contained in the dialaog. You can use it for validaton.
//Use a java robot class to cancel the dialog
Robot robot= new Robot();
robot.keyPress(KeyEvent.VK_ENTER);
//Since the current focus is on cancel.. else use robot.keyPress(KeyEvent.VK_TAB) as needed.
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.