0

I'm trying to launch a Firefox profile with add-ons in it, with selenium v3.12 and gecko-driver v2.10 and Firefox version 60.0, how-ever it seems that the custom profile is not working. below is my code

  static WebDriver driver;
    ProfilesIni profile = new ProfilesIni();
            myprofile = profile.getProfile("AutoProfile");
    System.setProperty("webdriver.gecko.driver", 
      "E:\\Library\\geckodriver-v0.21.0-win32\\geckodriver.exe");
            driver = new FirefoxDriver(myprofile);

The acutal error is on the

     driver = new FirefoxDriver(myprofile);

as

The constructor FirefoxDriver(FirefoxProfile) is undefined

1
  • Are you using maven? If yes, can you post your dependencies?
    – Alexey R.
    Commented Aug 3, 2018 at 9:17

3 Answers 3

0

Try this below line

WebDriver driver = new FirefoxDriver(myProfile);
1
  • updated the Question Commented Aug 3, 2018 at 6:44
0

In the code you need to initialize Firefox profile with the object of myprofile.

ProfilesIni profile = new ProfilesIni();
       FirefoxProfile myprofile = profile.getProfile("AutoProfile");
    System.setProperty("webdriver.gecko.driver", 
      "E:\\Library\\geckodriver-v0.21.0-win32\\geckodriver.exe");
         WebDriver driver = new FirefoxDriver(myprofile);

Also It's a bad practise to declare the WebDriver as static. Please refer the following link for more information.

2
  • I tried above, still same error occurs Commented Aug 3, 2018 at 7:12
  • Check the geckodriver path and update it correctly. Commented Aug 3, 2018 at 7:18
0

Try below code, it worked for me:

    System.setProperty("webdriver.gecko.driver", "Path of geckodriver.exe on your machine");

    ProfilesIni profile = new ProfilesIni();

    FirefoxProfile myprofile = profile.getProfile("Your Firefox Profile name");

    FirefoxOptions options=new FirefoxOptions().setProfile(myprofile);

    WebDriver driver=new FirefoxDriver(options);

    driver.get("Your application URL");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.