PhantomJsCloud Automation API
    Preparing search index...

    Class Tracing

    You can use tracing.start and tracing.stop to record a Chrome performance trace, which can be opened in Chrome DevTools or timeline viewer. stop returns it as base64 text; keep traces to 5 seconds or less (traces over 20 MB are refused).

    await page.tracing.start({ screenshots: true });
    await page.goto('https://www.google.com');
    const trace = await page.tracing.stop();

    Hierarchy

    • _PlatformObjBinding
      • Tracing
    Index
    • Starts recording a Chrome performance trace of the page, for Tracing.stop to return.

      Keep traces short: 5 seconds or less is recommended. A trace larger than 20 MB is refused (stop() fails and returns no trace), and a busy page can produce about 15 MB in 5 seconds (less while it sits behind pjsc's automation page).

      pjsc differences:

      • The recording stops by itself 5 seconds after start() when stop() was not called yet; stop() still returns that trace later in the same render. A trace never read is dropped when the render ends.
      • stop() returns the trace as base64 text (decode it to get the trace JSON); path is ignored, no file is written.
      • The trace categories are fixed (puppeteer's default set); categories is refused. screenshots: true adds screenshots.
      • Chrome's trace buffer is bounded: on a very busy page the recording can end before 5 seconds (the trace stays valid).
      • One trace at a time: start() fails while a trace is recording or waiting for its stop().
      • The base64 text is a third larger than the trace (up to about 27 MB).
      • The trace records the whole browser, so it can also show pjsc's own automation page beside yours.
      await page.tracing.start({ screenshots: true });
      await page.goto("https://example.com");
      const trace = await page.tracing.stop(); // base64 text of the trace JSON
      page.meta.store.set("trace", trace);

      Parameters

      • Optionaloptions: { screenshots?: boolean }

        screenshots: also record screenshots

      Returns Promise<void>

    • Stops the trace started by Tracing.start (or takes the one the 5-second automatic stop ended) and returns it as base64 text. Fails when no trace was started, or when the trace is larger than 20 MB. Several stop() calls at the same time all get the same trace.

      Returns Promise<string>