[英]Selenium Webdriver Donwload file path (NodeJS)
我正在尝试为Chrome浏览器设置下载位置,但遇到问题。
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();
我做错了什么或者传递自己的下载文件夹的正确方法是什么?
非常感谢!!
我终于找到答案了
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))
在NodeJS中,setUserPreferences不再具有实验性!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.