Skip to content

Instantly share code, notes, and snippets.

@FriendlyTester
Created October 16, 2014 11:04
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FriendlyTester/897c776c1fcf14e627c8 to your computer and use it in GitHub Desktop.
Save FriendlyTester/897c776c1fcf14e627c8 to your computer and use it in GitHub Desktop.
C# Proxy Using Firefox Driver
public void SettingUpAProxyUsingFirefoxDriver()
{
//Create a new Firefox profile
var firefoxProfile = new FirefoxProfile();
//Create a new proxy object
var proxy = new Proxy();
//Set the http proxy value, host and port.
proxy.HttpProxy = "localhost:8888";
//We then add this proxt setting to the Firefox profile we created
firefoxProfile.SetProxyPreferences(proxy);
//Then create a new Firefox Driver passing in the profile we created
//WebDriver we open a Firefox using this profile now
var Driver = new FirefoxDriver(firefoxProfile);
//Navigate to a url and look at the traffic being logged in Fiddler.
Driver.Navigate().GoToUrl("http://bbc.co.uk");
}
@CainDev
Copy link

CainDev commented Jul 31, 2018

public void LaunchMozilla()
{
var fireDriverService = FirefoxDriverService.CreateDefaultService();
var profileManager = new FirefoxProfileManager();
var proxy = new Proxy();

        fireDriverService.HideCommandPromptWindow = true;
        FirefoxOptions option = new FirefoxOptions();

        //"Settings"
        proxy.SocksProxy = textBox2.Text + ":" + textBox3.Text;
        option.Profile = profileManager.GetProfile("Selenium");
        option.Profile.SetProxyPreferences(proxy);

        controller.Driver = new FirefoxDriver(fireDriverService, option);
   }

That's my code incase anyone is wondering if its any different with an imported profile (Its not).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment