您可以使用Selenium Web驱动程序自动执行下载。您可以在Java代码中使用以下代码段获取浏览器下载首选项。
FirefoxProfile profile = new FirefoxProfile();profile.setPreference("browser.download.folderList", 2);profile.setPreference("browser.download.manager.showWhenStarting", false);profile.setPreference("browser.download.dir", "C:\downloads");profile.setPreference("browser.helperApps.neverAsk.openFile","text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,text/html,text/plain,application/msword,application/xml");
当d出窗口出现时,使用此类处理d出窗口。
Robot robot = new Robot();robot.keyPress(KeyEvent.VK_DOWN); robot.keyRelease(KeyEvent.VK_DOWN);robot.keyPress(KeyEvent.VK_ENTER); robot.keyRelease(KeyEvent.VK_ENTER);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)