4

I've looked at a lot of the other posts and none seem to have worked for me even though it's giving the same error.

I'm running bash through windows, all I'm trying to do is get the given code from npm selenium-webdrivers to load and even that's not working.

Here's the app.js:

require('chromedriver');
const webdriver = require('selenium-webdriver'),
  By = webdriver.By,
  until = webdriver.until;

var driver = new webdriver.Builder()
  .forBrowser('chrome')
  .build();

driver.get('http://www.google.com/ncr');
driver.findElement(By.name('q')).sendKeys('webdriver');
driver.findElement(By.name('btnG')).click();
driver.wait(until.titleIs('webdriver - Google Search'), 1000);
driver.quit();

Here's the Bash error when I run node app.js HERE

Any help would be appreciated

Justin Li
  • 91
  • 4
  • 11
  • are you sure the bash script has chrome and chromedriver at its PATH? – akiva Jul 09 '17 at 00:47
  • @akiva if it's the same as the environmnet variables settings through system properties, then yes. Otherwise mind guiding me through? – Justin Li Jul 09 '17 at 00:53
  • @JustinLi that error usually tells you Selenium doesn't have all the required software dependencies to execute your script. Do you have **[Java Runtime Environment](http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)** installed on your machine? Check **[this](https://stackoverflow.com/questions/36429436/how-do-i-solve-server-terminated-early-with-status-127-when-running-node-js-on)** post, maybe it will help. Cheers! – iamdanchiv Jul 09 '17 at 14:07
  • @iamdanchiv Thanks for you input, I do have JRE installed and it's still giving me 127 error – Justin Li Jul 10 '17 at 01:46

1 Answers1

1

You don't need to require chromedriver like that. install it globally npm install -g chromedriver and then try to run your script.

I had the same issue as you and I simply uninstalled chromedriver then reinstalled it.

npm uninstall -g chromedriver then npm install -g chromedriver

If you are looking for a walkthrough on getting up and running with nodejs webdriver check out youtube https://www.youtube.com/watch?v=YWhxSsj1upg&t=734s

codemon
  • 1,456
  • 1
  • 14
  • 26