admin管理员组

文章数量:1200985

Getting below error when starting nodejs server with selenium webdriver

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?

Getting below error when starting nodejs server with selenium webdriver

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?

How can I fix this error?

UPDATE

After downgrade nodejs version to Node v6.9.0, I am getting below error

/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)
Share Improve this question edited Nov 9, 2016 at 17:37 Gohel Kiran asked Nov 8, 2016 at 17:04 Gohel KiranGohel Kiran 1,1911 gold badge12 silver badges30 bronze badges 7
  • Check which version of Selenium you are using and which version of Node you have installed. – jmreicha Commented Nov 8, 2016 at 19:06
  • selenium webdriver version 3.0.1 node version v7.0.0 – Gohel Kiran Commented Nov 9, 2016 at 15:14
  • I had to roll back to 3.0.0-beta-4, maybe you can test it works with an older version? – jmreicha Commented Nov 9, 2016 at 19:41
  • can you please explain more? – Gohel Kiran Commented Nov 16, 2016 at 16:06
  • I had to change the version of selenium-webdriver to a different version to get it working again. I am using node v6.x.x, – jmreicha Commented Nov 16, 2016 at 17:45
 |  Show 2 more comments

3 Answers 3

Reset to default 11

npm i [email protected] did the trick for me.

P.S. also consider fixing that in your package.json if you have any.

Check your node version, you should be using version 6:

node --version

To install the latest node use:

nvm install v6.9.0
nvm use 6.9.0

I have just had the same problem which I solved by updating to node 6.x following the instructions on the node site.

Upgrading solved the first error but then I realised that I did not have any of the "additional components" mentioned in the selenium-webdriver installation instructions.

I opted to install the node chromedriver and was able to successfully run a selenium test.

本文标签: javascriptnodejs server error with seleniumwebdriverStack Overflow