16

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)
7
  • Check which version of Selenium you are using and which version of Node you have installed. Commented Nov 8, 2016 at 19:06
  • selenium webdriver version 3.0.1 node version v7.0.0 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? Commented Nov 9, 2016 at 19:41
  • can you please explain more? 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, Commented Nov 16, 2016 at 17:45

3 Answers 3

11

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

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

Sign up to request clarification or add additional context in comments.

3 Comments

After installing older version of webdriverjs I am getting below warning (node:22644) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: unexpected variable use
3.0.0-beta-4 is currently the latest version in which it works. Regardless whether using Node.js or not.
changing to [email protected] worked for me /app# node --version v4.4.2
9

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

4 Comments

current node version node -v v7.0.0
Long term support is not at v7 yet
Use nvm install lts/* to install the most recent version on LTS
This fixed it for me after upgrading to node v7.3.0
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.