是否可以更新Chrome WebDriver选项?

时间:2016-12-21 11:29:15

标签: java google-chrome selenium selenium-webdriver

创建WebDriver对象后是否可以更改Chrome WebDriver ChromeOptions / Capabilities?

Map<String, Object> preferences = new HashMap<String, Object>();
preferences.put("download.default_directory", "C:/downloads/");

ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", preferences);

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);

WebDriver driver = new ChromeDriver(capabilities);

// do some stuff with the driver
// is it possible to change the default download directory here?

编辑1: 我的网站上有几百个子页面,每个子页面都有很少的附件。我想创建目录树(每个目录包含仅连接到此特定子页面的文件)。

0 个答案:

没有答案