Cannot resolve constructor FirefoxDriver(org.openqa.selenium.firefox.FirefoxProfile)

Can someone help me with this piece of code. Currently it will complain on line #4 : webDriver = new FirefoxDriver(ff_ep_profiles) saying it cannot resolve constructor. I need to load my extensions hence I am creating a profile

FirefoxProfile ff_ep_profile = new FirefoxProfile(new File("C:\\Users\\admin\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\81uy033g.FirefoxEP"));
    FirefoxOptions option=new FirefoxOptions();
    option.setProfile(ff_ep_profile);
    webDriver = new FirefoxDriver(ff_ep_profile);

While working with Selenium v3.11.x, GeckoDriver v0.20.0 and Firefox Quantum v59.0.2 there are different option to invoke a new/existing Firefox Profile

If you are looking to use a new Firefox Profile on every run of your Test Execution you can use the following code block :

System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");
FirefoxOptions options = new FirefoxOptions();
options.setProfile(new FirefoxProfile());
WebDriver driver = new FirefoxDriver(options);
driver.get("https://www.google.com");

If you are looking to use an existing Firefox Profile on every run of your Test Execution first you have to create a Firefox Profile manually following the instructions at Creating a new Firefox profile on Windows.

Now you have 2 ways to invoke the Firefox Profile you have created as follows :

  • You can use the FirefoxOptions class to invoke the existing Firefox Profile and you can use the following code block :

    System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");
    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile testprofile = profile.getProfile("debanjan");
    FirefoxOptions opt = new FirefoxOptions();
    opt.setProfile(testprofile);
    WebDriver driver =  new FirefoxDriver(opt);
    driver.get("https://www.google.com");
    
  • You can also use the DesiredCapabilities class to set the existing Firefox Profile and later merge within an instance of FirefoxOptions and you can use the following code block :

    System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");
    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile testprofile = profile.getProfile("debanjan");
    DesiredCapabilities dc = DesiredCapabilities.firefox();
    dc.setCapability(FirefoxDriver.PROFILE, testprofile);
    FirefoxOptions opt = new FirefoxOptions();
    opt.merge(dc);
    WebDriver driver =  new FirefoxDriver(opt);
    driver.get("https://www.google.com");