4
votes

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

1
are you sure the bash script has chrome and chromedriver at its PATH? - akiva
@akiva if it's the same as the environmnet variables settings through system properties, then yes. Otherwise mind guiding me through? - Justin Li
@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 installed on your machine? Check this post, maybe it will help. Cheers! - iamdanchiv
@iamdanchiv Thanks for you input, I do have JRE installed and it's still giving me 127 error - Justin Li

1 Answers

1
votes

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