String path = "D:\dowmload"; ChromeOptions options = setDownloadsPath(path); //chromedriver.exe的路径 File file = new File("D:\chromedriver.exe") System.setProperty("webdriver.chrome.driver", file.getAbsolutePath()); ChromeDriver driver = new ChromeDriver(options);
public ChromeOptions setDownloadsPath(String path) { MapchromePrefs = new HashMap<>(); chromePrefs.put("download.default_directory", path); ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("prefs", chromePrefs); options.setCapability(ChromeOptions.CAPABILITY, options); return options; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)