Using Selenium Web-driver in Java, am trying to download a file on click of a link in an Application.
i.e. On click of a Link the download should begin without asking an option whether to save the file or not with Firefox 12 Browser.
I am Using browser.helperApps.neverAsk.saveToDisk method.
Actual Result:
When I run this code the file is not getting saved automatically, rather it is asking for an option to save or not. Am Using a Data driven Approach where I am getting the elements from an Excel File.
Can Anyone please help me out?
Below is code where browser.helperApps.neverAsk.saveToDisk
is used
public class Driver {
static WebDriver driver;
public static void main(String[] args) {
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", "d:\\");
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.ms-excel");
driver = new FirefoxDriver(profile);
driver.get("https://www.testapp.com");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
TestRunner.run(suiteToRun());
}
public static Test suiteToRun(){
TestSuite suite = new TestSuite();
System.out.println("Login Class");
suite.addTestSuite(LoginLogout.class);
return suite;
}
}