'The ChromeDriver could not be found on the current PATH in selenium nodejs
I am getting the below error while running the automation by using selenium in production server. My code is on filezila FTP application:
Error: The ChromeDriver could not be found on the current PATH. Please download the latest version of the ChromeDriver from http://chromedriver.storage.googleapis.com/index.html and ensure it can be found on your PATH.
at new ServiceBuilder (/home/ec2-user/bseSTP_schemeCode_node/node_modules/selenium-webdriver/chrome.js:161:13)
at Function.getDefaultService (/home/ec2-user/bseSTP_schemeCode_node/node_modules/selenium-webdriver/chrome.js:278:22)
at Function.createSession (/home/ec2-user/bseSTP_schemeCode_node/node_modules/selenium-webdriver/chromium.js:663:49)
at Function.createSession (/home/ec2-user/bseSTP_schemeCode_node/node_modules/selenium-webdriver/chrome.js:240:13)
at createDriver (/home/ec2-user/bseSTP_schemeCode_node/node_modules/selenium-webdriver/index.js:147:33)
at Builder.build (/home/ec2-user/bseSTP_schemeCode_node/node_modules/selenium-webdriver/index.js:712:16)
at startScript (/home/ec2-user/bseSTP_schemeCode_node/script.js:30:6)
at Object.<anonymous> (/home/ec2-user/bseSTP_schemeCode_node/script.js:161:1)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
While running it on local it is working fine.
Here is the code to run the script:
var webdriver = require("selenium-webdriver");
const { until } = require("selenium-webdriver");
const { By } = require("selenium-webdriver");
// let chromedriver = require("chromedriver");
const util = require("util");
chrome = require('selenium-webdriver/chrome');
// chrome.setDefaultService(new chrome.ServiceBuilder("C:/Vishal/tasks/24-03-2022/bseMaster_Upload_Automation/chromedriver.exe").build());
options = new chrome.Options();
options.addArguments("headless"); // note: without dashes
options.addArguments("disable-gpu");
// console.log(chromedriver.path);
async function startScript() {
// var driver = new webdriver.Builder()
// .withCapabilities(webdriver.Capabilities.chrome())
// .setChromeOptions(options)
// .build();
const driver = new webdriver.Builder()
.forBrowser('chrome').setChromeOptions(options)
.build();
// await driver.manage().window().maximize();
await driver.get("https://www.bsestarmf.in/Index.aspx");
await driver.quit();
}
What is the problem while running the code on server?
Thanks.
Solution 1:[1]
It sounds like you need to install the dependencies on your server, such as chromedriver and possibly also Chrome.
You've likely installed chromedriver locally at some point, which would explain why it works locally and not on the server.
Solution 2:[2]
I am just learning Selenium webdriver, n today i took the same error as yours (and solved it luckily xD). If you still need a solution, i am just going to add my point here: i dont know why did you commented:
// let chromedriver = require("chromedriver");
i used require("chromedriver"); without giving it as a variable and it worked with me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | J c |
| Solution 2 |
