我正在尝试在excel
下载CSV
和Selenium Grid
报告文件,但无法在所需位置查看下载的文件。
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting",false);
String path=System.getProperty("user.dir");
System.out.println(path);
profile.setPreference("browser.download.dir",path);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/msword,application/x-rar-compressed," + "application/octet-stream,application/csv,text/csv");
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setCapability(FirefoxDriver.PROFILE, profile);
cap.setBrowserName("firefox");
cap.setPlatform(Platform.WINDOWS);
WebDriver driver = new RemoteWebDriver(new URL("GRID_URL"),cap);
//WebDriver driver= new FirefoxDriver(profile);
driver.get("http://www.winzip.com/landing/open-rar-file.html");
driver.findElement(By.xpath("//*[@id='lan_img']")).click();
System.out.println("File downloaded at location::"+path);