Show IE “Save As” dialog using Watin

二次信任 提交于 2019-12-08 13:20:30

问题


Has anybody has done this? Navigating to a web page and pop up the save as dialog? In this way, the browser can handle the file type, html, pdf, etc...


回答1:


Do you need to this to be when a FileHandler is called or on a static webpage?

If it is on a Handler page where the content type is returned then according the latest WatiN release documentation then you can do as follows:

using(IE ie = new IE(someUrlToGoTo))
{
    FileDownloadHandler fileDownloadHandler = new FileDownloadHandler(fullFileName);
    ie.AddDialogHandler(fileDownloadHandler);

    ie.Link("startDownloadLinkId").Click();

    fileDownloadHandler.WaitUntilFileDownloadDialogIsHandled(15);
    fileDownloadHandler.WaitUntilDownloadCompleted(200);
}

Paul




回答2:


Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(".pdf");

run this Registry.



来源:https://stackoverflow.com/questions/3546047/show-ie-save-as-dialog-using-watin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!