🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# class:tracing ### class: Tracing v0.9.0 你可以使用 [`tracing.start`](#?product=Puppeteer&version=v1.11.0&show=api-tracingstartoptions) 和 [`tracing.stop`](#?product=Puppeteer&version=v1.11.0&show=api-tracingstop) 创建一个可以在 Chrome DevTools or [timeline viewer](https://chromedevtools.github.io/timeline-viewer/) 中打开的跟踪文件。 ``` await page.tracing.start({path: 'trace.json'});await page.goto('https://www.google.com');await page.tracing.stop(); ``` #### Methods - [tracing.start(options)](#?product=Puppeteer&version=v1.11.0&show=api-tracingstartoptions)v0.9.0 - [tracing.stop()](#?product=Puppeteer&version=v1.11.0&show=api-tracingstop)v0.9.0 ### Methods #### tracing.start(options)v0.9.0 - `options` <[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object")> - `path` <[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "String")> 跟踪文件写入的路径 - `screenshots` <[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean")> 捕获跟踪中的屏幕截图 - `categories` <[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array "Array")<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "String")>> 指定要使用的自定义类别替换默认值 - returns: <[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise")> 每个浏览器一次只能激活一条跟踪。 #### tracing.stop()v0.9.0 - returns: <[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise")<[Buffer](https://nodejs.org/api/buffer.html#buffer_class_buffer "Buffer")>> Promise which resolves to buffer with trace data. ![](images/pptr.png) puppeteer.js中文网|class:tracing puppeteer.js中文文档, puppeteer chrome, puppeteer firefox, puppeteer api 中文文档 puppeteer.js中文网包含了Puppeteer中文文档,最新资讯,应用案例等。Puppeteer 是一个 Node 库,它提供了一个高级 API 来通过 DevTools 协议控制 Chromium 或 Chrome。