Skip to content

Commit

Permalink
Puppeteer增加指定版本启动浏览器
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyong920 committed Jun 17, 2024
1 parent 5f93062 commit 6b8855c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/com/ruiyun/jvppeteer/core/Puppeteer.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,21 @@ private static void adapterLauncher(Puppeteer puppeteer) {
puppeteer.setLauncher(launcher);
}

/**
* 指定启动版本,开启浏览器
* @param options 启动参数
* @param version 浏览器版本
* @return 浏览器实例
* @throws IOException 异常
*/
public static Browser launch(LaunchOptions options, String version) throws IOException {
Puppeteer puppeteer = new Puppeteer();
if(StringUtil.isNotEmpty(version)){
puppeteer.setPreferredRevision(version);
}
return Puppeteer.rawLaunch(options, puppeteer);
}

/**
* 返回默认的运行的参数
* @param options 可自己添加的选项
Expand Down

0 comments on commit 6b8855c

Please sign in to comment.