nodejs服务器错误与seleniumwebdriver

使用selenium webdriver启动nodejs服务器时出现以下错误

ubuntu@ip-10-10-10-193:~/testenvoy$ node app.js /home/ubuntu/testenvoy/node_modules/selenium-webdriver/index.js:115 static createSession(...args) {} ^^^ SyntaxError: Unexpected token ... at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/home/ubuntu/testenvoy/controllers/test/all.js:2:17) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) r? 

我该如何解决这个错误?

UPDATE

将nodejs版本降级到Node v6.9.0后,出现以下错误

 /home/ubuntu/www.testenvoy.com/webdriver/node_modules/selenium-webdriver/lib/promise.js:2517 throw error; ^ WebDriverError: Firefox option was set, but is not a FirefoxOption: {} Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700' System info: host: 'WIN-MT0KFAH3HJN', ip: '10.10.10.10', os.name: 'Windows Server 2012 R2', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_112' Driver info: driver.version: FirefoxDriver at WebDriverError (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/selenium-webdriver/lib/error.js:27:5) at Object.checkLegacyResponse (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/selenium-webdriver/lib/error.js:505:15) at parseHttpResponse (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/selenium-webdriver/lib/http.js:509:13) at doSend.then.response (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/selenium-webdriver/lib/http.js:440:13) at process._tickCallback (internal/process/next_tick.js:103:7) From: Task: WebDriver.createSession() at Function.createSession (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/selenium-webdriver/lib/webdriver.js:777:24) at Function.createSession (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/selenium-webdriver/firefox/index.js:640:55) at createDriver (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/selenium-webdriver/index.js:167:33) at Builder.build (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/selenium-webdriver/index.js:629:16) at Query._callback (/home/ubuntu/www.testenvoy.com/webdriver/controllers/test/all.js:18:9) at Query.Sequence.end (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/mysql/lib/protocol/sequences/Sequence.js:86:24) at Query._handleFinalResultPacket (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/mysql/lib/protocol/sequences/Query.js:144:8) at Query.EofPacket (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/mysql/lib/protocol/sequences/Query.js:128:8) at Protocol._parsePacket (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/mysql/lib/protocol/Protocol.js:280:23) at Parser.write (/home/ubuntu/www.testenvoy.com/webdriver/node_modules/mysql/lib/protocol/Parser.js:74:12) 

       

网上收集的解决方案 "nodejs服务器错误与seleniumwebdriver"

npm i selenium-webdriver@3.0.0-beta-2为我做了诡计。

PS也考虑在你的package.json中解决这个问题。

检查你的节点版本,你应该使用版本6:

 node --version 

要安装最新的节点,请使用:

 nvm install v6.9.0 nvm use 6.9.0 

我刚才遇到了同样的问题,我按照节点站点上的说明更新到节点6.x。

升级解决了第一个错误,但后来我意识到,我没有任何“补充组件”在selenium-webdriver安装说明中提到的。

我select安装节点chromedriver ,并能够成功运行seleniumtesting。