0

我正在使用来自 JimEvans 的名为WebDriverProxyExamples的示例项目。这个项目使用 Selenium 和 FiddlerApplication。到目前为止,我对代码和响应代码所看到的感到满意。但是,当我尝试捕获AngularJs登录页面的响应代码时,它无法捕获响应代码并返回 0。

在此处输入图像描述

编辑:我尝试用于调试的代码片段

SessionStateHandler responseHandler = delegate(Session targetSession)
{
    if (printDebugInfo)
    {
        Console.WriteLine("DEBUG: Received response for resource with URL {0}", targetSession.fullUrl);
    }

    if (targetSession.fullUrl == targetUrl)
    {
        responseCode = targetSession.oResponse.headers.HTTPResponseCode;
        Console.WriteLine(targetSession.oResponse.headers);
        if (printDebugInfo)
        {
            Console.WriteLine("DEBUG: Found response for {0}, setting response code.", targetSession.fullUrl);
        }
    }
};

// Attach the event handler, perform the navigation, and wait for
// the status code to be non-zero, or to timeout. Then detach the
// event handler and return the response code.
FiddlerApplication.AfterSessionComplete += responseHandler;
driver.Url = targetUrl;
while (responseCode == 0 && DateTime.Now < endTime)
{
    System.Threading.Thread.Sleep(100);
}

FiddlerApplication.AfterSessionComplete -= responseHandler;
return responseCode;
4

1 回答 1

1

有几种可能的解释,包括您没有将正确的证书生成器(例如 makecert.exe)放在正确的位置。您应该修改 WebDriverProxyExample 代码以连接错误处理程序以进行显示:

 Fiddler.FiddlerApplication.OnNotification += delegate(object sender, NotificationEventArgs oNEA) { Console.WriteLine("** NotifyUser: " + oNEA.NotifyString); };
 Fiddler.FiddlerApplication.Log.OnLogString += delegate(object sender, LogEventArgs oLEA) { Console.WriteLine("** LogString: " + oLEA.LogString); };
于 2015-04-10T16:45:55.553 回答