Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Selenium Webdriver不加载文件路径(NodeJS)_Node.js_Selenium_Selenium Webdriver - Fatal编程技术网

Node.js Selenium Webdriver不加载文件路径(NodeJS)

Node.js Selenium Webdriver不加载文件路径(NodeJS),node.js,selenium,selenium-webdriver,Node.js,Selenium,Selenium Webdriver,我正试图为Chrome浏览器设置下载位置,但我被卡住了 const webdriver=require('selenium-webdriver'); const chrome=require('selenium-webdriver/chrome'); const chromeOptions=new chrome.Options(); chromeOptions.set('download.default_directory',uu dirname+'/download'); const buil

我正试图为Chrome浏览器设置下载位置,但我被卡住了

const webdriver=require('selenium-webdriver');
const chrome=require('selenium-webdriver/chrome');
const chromeOptions=new chrome.Options();
chromeOptions.set('download.default_directory',uu dirname+'/download');
const builder=等待新的builder()
.forBrowser('chrome')
.setChromeOptions(chromeOptions)
.build();
我做错了什么?传递我自己的下载文件夹的正确方法是什么

非常感谢

我终于知道了

const{Builder}=require('selenium-webdriver')
const chrome=require('selenium-webdriver/chrome')
const chromePrefs={'download.default_目录':_目录名+'/download'}
const chromeOptions=new chrome.Options().setUserPreferences(chromePrefs)
const driver=wait new Builder()
.forBrowser('chrome')
.setChromeOptions(chromeOptions)
.build()
.catch(e=>console.error(e))
在NodeJS中,setUserPreferences不再是实验性的

我终于知道了

const{Builder}=require('selenium-webdriver')
const chrome=require('selenium-webdriver/chrome')
const chromePrefs={'download.default_目录':_目录名+'/download'}
const chromeOptions=new chrome.Options().setUserPreferences(chromePrefs)
const driver=wait new Builder()
.forBrowser('chrome')
.setChromeOptions(chromeOptions)
.build()
.catch(e=>console.error(e))

在NodeJS中,setUserPreferences不再是实验性的

这里有一个Java的答案,但在这里可能也适用:@AndiCover setExperimentalOption在NodeJS chrome选项上不存在:-/这里有一个Java的答案,但在这里可能也适用:@AndiCover setExperimentalOption在NodeJS chrome选项上不存在:-/谢谢,伙计。你救了我的命。我花了半天时间想弄明白。谢谢你,伙计。你救了我的命。我花了半天时间想弄明白。