This is a migrated thread and some comments may be shown as answers.

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

1 Answer 164 Views
FiddlerCore
This is a migrated thread and some comments may be shown as answers.
Avinash
Top achievements
Rank 1
Avinash asked on 27 Feb 2015, 07:05 AM
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.

1 Answer, 1 is accepted

Sort by
0
Eric Lawrence
Telerik team
answered on 27 Feb 2015, 04:29 PM
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.

 
Tags
FiddlerCore
Asked by
Avinash
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
Share this question
or