I'm trying to set download location for Chrome browser but I'm stuck.
const webdriver = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const chromeOptions = new chrome.Options();
chromeOptions.set('download.default_directory', __dirname + '/download');
const builder = await new Builder()
.forBrowser('chrome')
.setChromeOptions(chromeOptions)
.build();
What am I doing wrong or what is the correct method to pass my own download folder?
Many thanks!!
I've finally find out.
const { Builder } = require('selenium-webdriver')
const chrome = require('selenium-webdriver/chrome')
const chromePrefs = { 'download.default_directory': __dirname + '/download' }
const chromeOptions = new chrome.Options().setUserPreferences(chromePrefs)
const driver = await new Builder()
.forBrowser('chrome')
.setChromeOptions(chromeOptions)
.build()
.catch(e => console.error(e))
in NodeJS setUserPreferences are nolonger experimental!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.