我正在使用来自 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;