【发布时间】:2017-02-14 05:41:58
【问题描述】:
测试是通过点击下载模板链接下载文件。当我在本地机器上执行脚本时,它运行良好。能够创建下载文件夹,下载的文件存储在新创建的“下载”文件夹中。 但是当我将它集成到詹金斯管道时,没有创建文件夹,也没有下载文件。 注意:在 jenkins 管道中,脚本是在 selenium 网格中使用 chrome 执行的。请参考chrome驱动中的配置。
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);
【问题讨论】:
标签: selenium jenkins selenium-chromedriver selenium-grid