(async function firstTest() { // // chromedriver 的路径 const chromedriverPath = path.join(__dirname, 'chrome','webdriver', '114','chromedriver.exe'); // // Chromium 的路径 const chromePath = path.join(__dirname, 'chrome','114.0.5735.45', 'chrome.exe'); console.log(chromedriverPath); console.log(chromePath); let driver; try { driver = await new Builder() .forBrowser(Browser.CHROME) // .setChromeDriverPath(chromedriverPath) .setChromeOptions(options.setChromeBinaryPath(chromePath)) .build(); await driver.get('https://www.163.com'); let title = await driver.getTitle(); console.log(title); } catch (e) { console.log(e) } finally { // await driver.quit(); console.log('quit'); } }())
可以指定浏览器,当时驱动无法指定办法。
但运行,是可以正常运行的。
.setChromeDriverPath(chromedriverPath)
说是无效函数