Skip to content

Commit 7e4b1b3

Browse files
Use connect/disconnect for Puppeteer
Signed-off-by: Francis Bouvier <[email protected]>
1 parent cf40025 commit 7e4b1b3

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

puppeteer/cdp.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,14 @@ const baseURL = process.env.BASE_URL ? process.env.BASE_URL : 'http://127.0.0.1:
2424
// runs
2525
const runs = process.env.RUNS ? parseInt(process.env.RUNS) : 100;
2626

27-
const executablePath = process.env.CHROME_PATH ? process.env.CHROME_PATH : '/usr/bin/google-chrome';
28-
2927
// measure general time.
3028
const gstart = process.hrtime.bigint();
3129
// store all run durations
3230
let metrics = [];
3331

3432
(async () => {
35-
// Launch the browser and open a new blank page
36-
const browser = await puppeteer.launch({
37-
executablePath: executablePath,
33+
// Connect to the browser and open a new blank page
34+
const browser = await puppeteer.connect({
3835
browserURL: browserAddress,
3936
});
4037

@@ -101,7 +98,7 @@ let metrics = [];
10198
metrics[run] = process.hrtime.bigint() - rstart;
10299
}
103100

104-
await browser.close();
101+
await browser.disconnect();
105102

106103
const gduration = process.hrtime.bigint() - gstart;
107104

0 commit comments

Comments
 (0)