|
1 | 1 | import * as puppeteer from "puppeteer-core";
|
2 | 2 | import { Page } from "puppeteer-core";
|
3 | 3 | import { BenchmarkOptions, wait } from "./common.js";
|
| 4 | +import * as fs from "node:fs"; |
| 5 | +import * as path from "node:path"; |
4 | 6 |
|
5 | 7 | export async function checkElementNotExists(page: Page, selector: string) {
|
6 | 8 | let start = Date.now();
|
@@ -109,16 +111,27 @@ export async function startBrowser(benchmarkOptions: BenchmarkOptions): Promise<
|
109 | 111 | const window_width = width,
|
110 | 112 | window_height = height;
|
111 | 113 |
|
| 114 | + // delete the folder './chrome_profile' if it exists |
| 115 | + const dir = "chrome_profile"; |
| 116 | + if (fs.existsSync(dir)) { |
| 117 | + fs.rmSync(dir, { recursive: true }); |
| 118 | + } |
| 119 | + fs.mkdirSync(dir); |
| 120 | + fs.mkdirSync(path.join(dir,"Default")); |
| 121 | + fs.copyFileSync("Preferences", path.join(dir, "Default","Preferences")); |
| 122 | + |
112 | 123 | const args = [
|
113 | 124 | `--window-size=${window_width},${window_height}`,
|
114 | 125 | "--js-flags=--expose-gc", // needed for gc() function
|
115 | 126 | "--no-default-browser-check",
|
116 | 127 | "--disable-sync",
|
117 | 128 | "--disable-first-run-ui", // avoid popup "you can open bookmarks ..."
|
118 |
| - "--no-first-run", |
| 129 | + "--no-first-run", |
| 130 | + "--ash-no-nudges", |
119 | 131 | "--disable-extensions",
|
120 | 132 | "--disable-features=Translate", // avoid translation popups
|
121 | 133 | "--disable-features=PrivacySandboxSettings4", // avoid privacy popup
|
| 134 | + "--user-data-dir=./chrome_profile" |
122 | 135 | ];
|
123 | 136 | if (benchmarkOptions.headless) args.push("--headless=new");
|
124 | 137 |
|
|
0 commit comments