Firefox download

FirefoxProfile firefoxProfile = new FirefoxProfile();

firefoxProfile.setPreference("browser.download.folderList",2);
firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false);
firefoxProfile.setPreference("browser.download.dir","c:\\downloads");
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv");

WebDriver driver = new FirefoxDriver(firefoxProfile);


------------------------------------------------------------------------
driver.findElement(By.linkText("Instant Selenium Testing Tools
Starter")).click();
add below code it ll work
Robot robo=new Robot();
robo.keyPress(KeyEvent.VK_ENTER);

----------------------------------------------------------------------

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.manager.focusWhenStarting", false);
profile.setPreference("browser.download.useDownloadDir", true);
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.download.manager.alertOnEXEOpen", false);
profile.setPreference("browser.download.manager.closeWhenDone", true);
profile.setPreference("browser.download.manager.showAlertOnComplete", false);
profile.setPreference("browser.download.manager.useWindow", false);
/* you will need to find the content-type of your app and set it here. */
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream");
profile.setPreference("browser.download.dir",path);

String file_types = "application/acrobat, application/nappdf, application/x-pdf, application/vnd.pdf, text/pdf, text/x-pdf, " +
"text/comma-separated-values,text/csv,application/pdf, application/x-msdos-program, application/x-unknown-application-octet-stream,"
+ "application/vnd.ms-powerpoint, application/excel, application/vnd.ms-publisher, application/x-unknown-message-rfc822, application/vnd.ms-excel,"
+ "application/msword, application/x-mspublisher, application/x-tar, application/zip, application/x-gzip, application/x-stuffit,"
+"application/vnd.ms-works, application/powerpoint, application/rtf, application/postscript, application/x-gtar,"
+ "video/quicktime, video/x-msvideo, video/mpeg, audio/x-wav, audio/x-midi, audio/x-aiff, text/plain, application/vnd.ms-excel [official],"
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/msexcel, application/x-msexcel,"
+ "application/x-excel, application/vnd.ms-excel, application/excel, application/x-ms-excel, application/x-dos_ms_excel,"
+ "text/csv, text/comma-separated-values, application/octet-stream, application/haansoftxls, application/msexcell,"
+ "application/softgrid-xls, application/vnd.ms-excel, x-softmaker-pm";

profile.setPreference("browser.helperApps.neverAsk.saveToDisk", file_types);

File fin = new File(path);
if (!fin.exists()) {
fin.mkdirs();
}

File pathToBinary = new File("C:/Program Files (x86)/FrontMotion/Firefox/firefox.exe");
FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
ESGManagerFireFoxWebDriver esgManagerFireFoxWebDriver = new ESGManagerFireFoxWebDriver(ffBinary,profile);
esgManagerFireFoxWebDriver.manage().window().setPosition(new Point(0,0));
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
Dimension dim = new Dimension((int) screenSize.getWidth(), (int) screenSize.getHeight());
esgManagerFireFoxWebDriver.manage().window().setSize(dim);
return esgManagerFireFoxWebDriver;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值