1
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);
timbre timbre
  • 12,648
  • 10
  • 46
  • 77
  • 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 Answers1

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

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