Get pid of a browser launched with Playwright

Viewed 915

How can I get the pid of a browser launched with Playwright ? I tried : browser.process().pid but it did not work unfortunately.

1 Answers

You cannot apply process() on browser context but only on browserServer, which requires a launchServer() first place (and not regular launch()). see the docs about browserServer.process().

You will need to launch the server like this to get an instance with a valid pid:

  const browserServer = await playwright.chromium.launchServer()
  const pid = await browserServer.process().pid
  console.log(pid)
Related