Search code examples
node.jsplaywright

Get pid of a browser launched with Playwright


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


Solution

  • 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)