I am trying to change the default download directory for Chrome using JavaScript (TypeScript). I attempted to set options like this:
let options = webdriver.ChromeOptions;
options.add_argument("download.default_directory=C:/Downloads")
let driver = webdriver.chrome(options);
However, the options are being set to undefined and ChromeOptions does not exist on webdriver.
Below is the full code snippet:
let webdriver = require('selenium-webdriver');
let chrome = require('selenium-webdriver/chrome');
let chromedriver = require('chromedriver');
chrome.setDefaultService(new chrome.ServiceBuilder(chromedriver.path).build());
// let driver = new webdriver.Builder()
// .withCapabilities(webdriver.Capabilities.chrome())
// .build();
let options = webdriver.ChromeOptions;
options.add_argument("download.default_directory=C:/Downloads")
let driver = webdriver.chrome(options);
let figma = 'https://www.figma.com/';
driver.get(figma).then(
backup
);
function backup() {
driver.sleep(3000);
driver.quit();
}