V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐关注
Meteor
JSLint - a JavaScript code quality tool
jsFiddle
D3.js
WebStorm
推荐书目
JavaScript 权威指南第 5 版
Closure: The Definitive Guide
nbagigi

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

  •  
  •   nbagigi · Mar 28, 2024 · 1770 views
    This topic created in 770 days ago, the information mentioned may be changed or developed.
    
            (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) 说是无效函数

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5742 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 03:45 · PVG 11:45 · LAX 20:45 · JFK 23:45
    ♥ Do have faith in what you're doing.