nodejs 使用 selenium-webdriver,如何使用指定文件夹的 chromedriver.exe 版本

24次阅读

共计 695 个字符,预计需要花费 2 分钟才能阅读完成。


        (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) 说是无效函数

正文完
 0