2

我正在 WatiN 中编写一些回归测试,并且需要发出几个 POST Web 请求。请求工作正常,但我收到一个烦人的对话框,询问我是否要保存文件或在线查找程序以打开它。导致这种情况的代码行是:

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

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

4

1 回答 1

2

这是我的答案:

Navigate2() 方法如下所示:

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

标志可以定义为枚举 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,它取消了下载框。希望这可以帮助某个地方的人

于 2011-06-23T18:27:48.240 回答