BeforeRequest event not raised when fiddler using with selenium(chrome webdriver)

2 posts, 0 answers
  1. Avinash
    Avinash avatar
    10 posts
    Member since:
    Jan 2015

    Posted 27 Feb 2015 Link to this post

    Hi Eric,

          BeforeRequest event not raised when fiddler using with selenium(chrome webdriver).

         Coded as follows


                   CONFIG.bCaptureCONNECT = true;
                CONFIG.IgnoreServerCertErrors = true;
                CONFIG.bMITM_HTTPS = true;
               
                FiddlerApplication.BeforeRequest += delegate(Session oSession)
                {
                    Console.WriteLine("Request URL {0}", oSession.fullUrl);            
                };
                var cert = InstallCertificate();
                int proxyPort = StartProxy(0);
                OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
                proxy.HttpProxy = string.Format("127.0.0.1:{0}", proxyPort);
                ChromeOptions options = new ChromeOptions();
                options.Proxy = proxy;

    IWebDriver Driver = new ChromeDriver(@"C:\chromedriver_win32", options);
              
                Console.WriteLine("Certificate {0}", cert);
                Driver.Navigate().GoToUrl(<url>);
             
     public static bool InstallCertificate()
            {

                if (!Fiddler.CertMaker.rootCertExists())
                {
                    if (!Fiddler.CertMaker.createRootCert())
                        return false;

                    if (!Fiddler.CertMaker.trustRootCert())
                        return false;
                    X509Store certStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
                    certStore.Open(OpenFlags.ReadWrite);
                    try
                    {
                        certStore.Add(Fiddler.CertMaker.GetRootCertificate());
                    }
                    finally
                    {
                        certStore.Close();
                    }
                }

                return true;
            }

    private static int StartProxy(int desiredPort)
            {   
               FiddlerCoreStartupFlags flags = FiddlerCoreStartupFlags.DecryptSSL & FiddlerCoreStartupFlags.AllowRemoteClients & FiddlerCoreStartupFlags.CaptureFTP & FiddlerCoreStartupFlags.ChainToUpstreamGateway & FiddlerCoreStartupFlags.MonitorAllConnections & FiddlerCoreStartupFlags.CaptureLocalhostTraffic;
               FiddlerApplication.Startup(desiredPort, flags);       
               return FiddlerApplication.oProxy.ListenPort;
            }

    Thank you,

    Regards,
    Avinash.
  2. Eric Lawrence
    Admin
    Eric Lawrence avatar
    833 posts

    Posted 27 Feb 2015 Link to this post

    Hi, Avinash--

    The C# & operator doesn't work like you think it does.

    Change your code to:

      FiddlerCoreStartupFlags flags = FiddlerCoreStartupFlags.Default;

    Regards,
    Eric Lawrence
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top