Fiddler核心,targetSession.fullUrl与页面上的图片网址不匹配

时间:2014-02-24 22:01:45

标签: c# selenium selenium-webdriver fiddler fiddlercore

我正在使用Selenium webdriver,c#bindings和fiddler core。我正在使用fiddler core从应用程序页面上的图像中获取响应。

目前我可以为url和targetSession.status输出targetSession.fullUrl,由于某种原因它不匹配逻辑测试。

我现在没有想到为什么这不起作用。

// Hook up the event for monitoring proxied traffic.
FiddlerApplication.AfterSessionComplete += delegate(Session targetSession)
{
    // Outputs the image url along with the other resources
    Console.WriteLine("Requested resource from URL {0} responseCode {1}",
    targetSession.fullUrl, targetSession.responseCode);

    // does output the one item with an response code that is not 200
   if (targetSession.responseCode != 200)
   {
    Console.WriteLine("Incorrect Status: {0}, {1}, {2} ", targetSession.fullUrl, 
    targetSession.responseCode, targetSession.RequestMethod);
   }

   // neither of these match the image url
   if (targetSession.fullUrl == targeturl && targetSession.responseCode == 200)
   {
    Console.WriteLine("Image is present: " + targetSession.fullUrl);
   }
   else if (targetSession.fullUrl == targeturl && targetSession.responseCode != 200)
   {
    Console.WriteLine("Image is not present: " + targetSession.fullUrl + 
    targetSession.responseCode);
   }
};

1 个答案:

答案 0 :(得分:1)

预期和实际结果是什么?您是否忘记启用HTTPS解密?您是否检查过页面上的URL是否将HTTP / 3xx重定向到其他图像?