I am trying to login on facebook.com with selenium-webdriver.
var webdriver = require('selenium-webdriver'),
By = require('selenium-webdriver').By,
until = require('selenium-webdriver').until;
var driver = new webdriver.Builder()
.forBrowser('firefox')
.build();
driver.get('https://www.facebook.com/login');
driver.findElement(By.id('email')).sendKeys('****');
driver.findElement(By.id('pass')).sendKeys('*****');
driver.findElement(By.id('loginbutton')).click();
driver.findElement(By.linkText('Settings')).then(function(element) {
console.log('Yes, found the element');
}, function(error) {
console.log('The element was not found, as expected');
});
driver.quit();
It is giving error:
/home/shubham/node_modules/selenium-webdriver/index.js:25 const builder = require('./builder'); ^^^^^ SyntaxError: Use of const in strict mode. at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/home/shubham/Music/amazon_login/test_22_4_16/sel_login.js:1:79) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32)
node --version
v0.10.37
npm --version
1.4.28
protractor --version
Version 3.2.2
Updating nodejs
solved the issue:
npm cache clean -f
sudo npm install -g n
sudo n stable
node --version
node app.js
You have to run the second and third command as root/administrator.
n stable
wouldn't do the trick for me. On the other hand,
nvm install stable
That actually got me to last nodejs version. Apparently n stable
won't get pass v0.12.14
for me. I really don't know why.
Note: nvm
is Node Version Manager, you can install it from its github page. Thanks @isaiah for noting that nvm
is not a known command.
For me it was more simple to solve, just going to the Node web site, get and install the LTS version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With