Reputation: 1181
To install the chromedriver and selenium-webdriver I used
npm install chromedriver --save
npm install selenium-webdriver --save
After running this code, the new chrome window opened with Google like it should:
var webDriver = require(‘selenium-webdriver’);
var chrome = require(‘selenium-webdriver/chrome’);
var path = require(‘chromedriver’).path;
var service = new chrome.ServiceBuilder(path).build();
chrome.setDefaultService(service);
var driver = new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.chrome())
build();
driver.get(‘https://www.google.com’);
After deploying the application on my mac, here’s the error I get: Uncaught (in promise) Error: spawn ENOTDIR
-Any help would be appreciated, thank you!
Upvotes: 0
Views: 1323
Reputation: 767
You need to follow the steps:
Install selenium webdriver
npm install selenium-webdriver --save
Download the chrome webdriver
ChromeDriver Home
Install chromedriver
npm install chromedriver --chromedriver_filepath=/Users/**/chromedriver_mac64.zip
Javascript code
const {Builder, By, Key, until, Capabilities} = require('selenium-webdriver');
console.log(require('chromedriver'));
var chromeCapabilities = Capabilities.chrome();
var chromeOptions = {
'args': ['--test-type', '--start-maximized'],
'prefs': {
'download.default_directory': '/Users/**/app/output/'
}
};
chromeCapabilities.set('chromeOptions', chromeOptions);
(async function example() {
let driver = await new Builder().forBrowser('chrome')
.withCapabilities(chromeCapabilities)
.build();
console.log(await driver.getCapabilities());
try {
await driver.get('http://www.google.com');
await driver.wait(until.elementLocated(By.id('lst-ib')), 20000);
} finally {
await driver.quit();
}
})();
Upvotes: 1