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.
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.