Puppeteer 中文文档v25.8.0

BrowserProvider.getExecutablePath() 方法

获取已解压归档中可执行文件的相对路径。

签名

interface BrowserProvider {
  getExecutablePath(options: {
    browser: Browser;
    buildId: string;
    platform: BrowserPlatform;
  }): Promise<string> | string;
}

参数

参数

类型

说明

options

{ browser: Browser; buildId: string; platform: BrowserPlatform; }

浏览器、buildId 和平台

返回值:

Promise<string> | string

可执行文件的相对路径

示例

// Electron uses simple structure
getExecutablePath() {
  return 'chromedriver/chromedriver';
}

// Custom provider with platform-specific paths
getExecutablePath(options) {
  return `binaries/${options.browser}-${options.platform}`;
}