Show IE “Save As” dialog using Watin

2019-06-10 03:03发布

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...

2条回答
叛逆
2楼-- · 2019-06-10 03:32

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

查看更多
迷人小祖宗
3楼-- · 2019-06-10 03:37

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

run this Registry.

查看更多
登录 后发表回答