public class download {
public static WebDriver driver;
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.gecko.driver", "/home/ranjith/Downloads/geckodriver");
//driver = new FirefoxDriver();
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.dir", "/home/ranjith/Downloads");
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
profile.setPreference( "browser.download.manager.showWhenStarting", false );
profile.setPreference( "pdfjs.disabled", true );
driver = new FirefoxDriver(profile);
driver.get("http://toolsqa.com/automation-practice-form/");
driver.findElement(By.linkText("Test File to Download")).click();
Thread.sleep(5000);
//driver.close();
}
}
要求在 Eclipse 中删除参数配置文件以匹配 FirefoxDriver 可以帮助解决这个问题。
此行抛出错误
driver = new FirefoxDriver(profile);