0
測試是通過單擊下載模板鏈接來下載文件。當我在本地機器上執行腳本時,它運行得很完美。能夠創建下載文件夾,並且下載的文件存儲在新創建的「下載」文件夾中。 但是,當我將它集成到詹金斯管道時,沒有創建文件夾,也沒有下載文件。 注意:在jenkins管道中,腳本是在硒網格中使用chrome執行的。請參閱chrome驅動程序中的配置。Selenium:無法在Jenkins管道中創建要下載的文件夾和文件
HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", System.getProperty("user.dir") + "\\src\\main\\resources\\downloads");
ChromeOptions options = new ChromeOptions();
HashMap<String, Object> chromeOptionsMap = new HashMap<String, Object>();
options.setExperimentalOption("prefs", chromePrefs);
options.addArguments("--test-type");
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(ChromeOptions.CAPABILITY, chromeOptionsMap);
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(ChromeOptions.CAPABILITY, options);
driver = new RemoteWebDriver(new URL(seleniumGridUrl), cap);