Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding BeforeRemoteHttpRequest event to .NET RemoteWebDriver
This commit adds the ability for advanced users of the .NET bindings RemoteWebDriver class to modify the HTTP command sent from the .NET WebDriver code to the remote WebDriver server. Note carefully that this **DOES NOT** modify the HTTP request between the browser and the web server, and is not a mechanism for getting access to that HTTP request. Usage of this new event would look something like this: public void StartDriver() { HttpCommandExecutor executor = new HttpCommandExecutor( new Url("http://localhost:4444/wd/hub"), TimeSpan.FromSeconds(60)); executor.BeforeRemoteHttpRequest += BeforeRemoteHttpRequestHandler; ICapabilities capabilities = new ChromeOptions().ToCapabilities(); IWebDriver driver = new RemoteWebDriver(executor, capabilities); } public void BeforeRemoteHttpRequestHandler( object sender, BeforeRemoteHttpRequestEventArgs e) { // Note: WebRequest.DefaultWebProxy is an IWebProxy implementation. // This could be anything, from adding additional headers, to modifying // the content of the request. Use with extreme caution. e.Request.Proxy = WebRequest.DefaultWebProxy; e.Request.AutomaticDecompression = DecompressionMethods.GZip }
- Loading branch information