Interop.SHDocVw Navigate2()方法显示不需要的下载框

时间:2011-06-23 15:37:26

标签: watin shdocvw http-post

我正在WatiN中编写一些回归测试,需要做几个POST Web请求。请求工作正常,但我得到一个恼人的对话框询问我是否要保存文件或在线查找程序打开它。导致此问题的代码行是:

browser.Navigate2(ref uri, ref nflags, ref ntargetFrame, 
                  ref dataBytes, ref headers);

是否有人熟悉Navigate2()方法?关于如何摆脱这个下载框的想法?

1 个答案:

答案 0 :(得分:2)

以下是我的回答:

Navigate2()方法如下所示:

HRESULT Navigate2(
    VARIANT *URL,
    VARIANT *Flags,
    VARIANT *TargetFrameName,
    VARIANT *PostData,
    VARIANT *Headers
);

标志可以定义为enum BrowserNavConstants,如下所示:

typedef enum BrowserNavConstants {
    navOpenInNewWindow = 0x1,
    navNoHistory = 0x2,
    navNoReadFromCache = 0x4,
    navNoWriteToCache = 0x8,
    navAllowAutosearch = 0x10,
    navBrowserBar = 0x20,
    navHyperlink = 0x40,
    navEnforceRestricted = 0x80,
    navNewWindowsManaged = 0x0100,
    navUntrustedForDownload = 0x0200,
    navTrustedForActiveX = 0x0400,
    navOpenInNewTab = 0x0800,
    navOpenInBackgroundTab = 0x1000,
    navKeepWordWheelText = 0x2000,
    navVirtualTab = 0x4000,
    navBlockRedirectsXDomain = 0x8000,
    navOpenNewForegroundTab = 0x10000
} BrowserNavConstants;

我使用了navUnstrustedForDownload,它取消了下载框。希望这可以帮助某人