-1

Can anyone help to create a profile and set options using firefox (gecko driver) to automatically download files in selenium webdriver - java. I have already searched a lot of options googling around, and nothing much worked. So posting my query on stack overflow. Please help with some code snippet if possible. This is for selenium 3 and firefox version 52.

Thanks in advance.

bhargav desai
  • 89
  • 1
  • 3
  • 11
  • See your answer here https://stackoverflow.com/questions/36309314/set-firefox-profile-to-download-files-automatically-using-selenium-and-java?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Anton May 10 '18 at 15:23
  • @Anton : Had seen this one earlier. It did not work :) – bhargav desai May 10 '18 at 15:31
  • See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) The expectation on SO is that the user asking a question not only does research to answer their own question but also shares that research, code attempts, and results. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – JeffC May 10 '18 at 18:32

1 Answers1

0

1/ create a new firefox profile manualy in firefox.exe -p

2/ run firefox with this new profile and set up to automaticly download PDF files

3/ use this:

@BeforeClass
    public static void setUpClass() {

        FirefoxOptions options = new FirefoxOptions();

        ProfilesIni allProfiles = new ProfilesIni();         
        FirefoxProfile selenium_profile = allProfiles.getProfile("NAME OF THE NEW FIREFOX PROFILE");
        options.setProfile(selenium_profile);

        options.setBinary("PATH TO FIREFOX.EXE");
        System.setProperty("webdriver.gecko.driver", "PATH TO GECKODRIVER.EXE");
        driver = new FirefoxDriver(options);
        driver.manage().window().maximize();

    }

using existing custom firefox profile, you can run your test with almost any firefox setting modification (proxy setings, 1 imported certificate with no asking, extensions, etc.)

No more need to specify in code:

FirefoxProfile selenium_profile = new FirefoxProfile();
        selenium_profile.setPreference...
pburgr
  • 1,526
  • 1
  • 9
  • 24