Now i have those error:
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.
I will run script at another computer, so setting environment variable not better solution
You can download the script into your project directory and use
let options = new Options();
const path = join(__dirname, './yourdriver')
options.setBinary(path)
let builder = new Builder().forBrowser('chrome')
builder = builder.setChromeOptions(options)
let driver = await builder.build();
Else
let webdriver = require('selenium-webdriver');
let chrome = require('selenium-webdriver/chrome');
let path = require('chromedriver').path;
let service = new chrome.ServiceBuilder(path).build();
chrome.setDefaultService(service);
var driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.chrome()).build();
Dont forget to run npm i --save chromedriver
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.