我正在使用名为WebDriverProxyExamples的JimEvans的示例项目。该项目使用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;
答案 0 :(得分: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); };