0

I installed webdriverjs on mac machine and tried to run a sample script from here as below

var webdriver = require('selenium-webdriver');
var browser = new webdriver.Builder().usingServer().withCapabilities({'browserName': 'chrome' }).build();

browser.get('http://en.wikipedia.org/wiki/Wiki');
browser.findElements(webdriver.By.css('[href^="/wiki/"]')).then(function(links){
    console.log('Found', links.length, 'Wiki links.' )
    browser.quit();
});

but I am receiving error

static createSession(...args) {}
                       ^^^
SyntaxError: Unexpected token ...

node is already installed on my mac

user1207289
  • 3,060
  • 6
  • 30
  • 66

1 Answers1

0

As per comment above and after searching for an answer , came to know that the error was due to node version. So i had to update my node version.

Here is the process I followed.

When I tried to update node from brew update brew doctor brew upgrade node

it gave me error Error: node not installed , after searching came to know that this is because node on my mac was packaged installation and not through homebrew so I had to remove previous installation and install fresh node and I followed this from here

Note: If you follow links above and when you do ./uninstall-node.sh the terminal will stop for you to press enter, only then the script will start. Afterwards just do

brew update && brew install node to install fresh node. Now node --version gives me v8.9.0 and the the test runs immidiately after upgrading node

user1207289
  • 3,060
  • 6
  • 30
  • 66