System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe");
ProfilesIni profile2 = new ProfilesIni();
FirefoxProfile profile3 = profile2.getProfile("AutoProfile");
profile3.setPreference("browser.popups.showPopupBlocker", false);
profile3.setPreference("browser.download.dir", "D:\\WebDriverDownloads");
profile3.setPreference("browser.download.folderList", 2);
profile3.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;");
profile3.setPreference( "browser.download.manager.showWhenStarting", false );
profile3.setPreference( "pdfjs.disabled", true );
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(profile3);
WebDriver driver = new FirefoxDriver(firefoxOptions);
Asked
Active
Viewed 311 times
1

timbre timbre
- 12,648
- 10
- 46
- 77

Rajat Prajapati
- 23
- 6
-
what is the reason you are using that preference? showPopupBlocker preference is used to show/hide an icon in the status bar when a pop-up is blocked. – theGuy Aug 21 '18 at 19:30
1 Answers
0
The most probhable reason you are seeing a java.lang.NullPointerException
is because the Firefox Profile which you are trying to use i.e. AutoProfile doesn't exist (yet to be created) on your local system.
Solution
- Before you start using the Firefox Profile AutoProfile ensure that this Firefox Profile exists in your local system. You can create a Firefox Profile manually following the instructions at Creating a new Firefox profile on Windows.
- To configure auto downloads
setPreference("browser.popups.showPopupBlocker", false)
is not required so you can remove it. - Execute your
@Test
. - Here you can find a detailed discussion on how to use a new/existing Firefox Profile for your tests

undetected Selenium
- 183,867
- 41
- 278
- 352
-
@RajatPrajapati My answer was to address yous issue regarding `java.lang.NullPointerException`. If your requirement have changed, feel free to raise a new question. Stackoveflow volunteers will be happy to help you out. – undetected Selenium Aug 21 '18 at 19:59
-
ok.....I got rid of NullPointerException. However still auto download not working – Rajat Prajapati Aug 21 '18 at 20:02