Playwright系列(4):Trace Viewer

简介: Playwright系列(4):Trace Viewer

大家好,我是阿萨。 昨天学习了如何录制脚本,大家每个人都会录制脚本后,调试脚本的时候需要查看每一步的执行记录。 Trace Viewer可是帮上大忙了

Playwright Trace Viewer是一个GUI工具,可以让你探索测试的Playwright记录痕迹,这意味着你可以回溯和前进你的测试的每个动作,并直观地看到每个动作中发生了什么。


记录一个Trace


同步记录:


browser = chromium.launch()context = browser.new_context()# Start tracing before creating / navigating a page.context.tracing.start(screenshots=True, snapshots=True, sources=True)page = context.new_page()page.goto("https://playwright.dev")# Stop tracing and export it into a zip archive.context.tracing.stop(path = "trace.zip")


异步记录:


browser = await chromium.launch()context = await browser.new_context()# Start tracing before creating / navigating a page.await context.tracing.start(screenshots=True, snapshots=True, sources=True)page = await context.new_page()await page.goto("https://playwright.dev")# Stop tracing and export it into a zip archive.await context.tracing.stop(path = "trace.zip")


用上面的代码将会记录所有痕迹,同时保存在trace.zip的文件里。


打开Trace 记录


你可以使用 Playwright CLI 或在浏览器中的 trace.playwright.dev 打开已保存的跟踪。


playwright show-trace trace.zip

查看Trace


通过点击每个动作或使用时间轴悬停来查看测试的痕迹,并查看动作前后的页面状态。在测试的每个步骤中检查日志、源和网络。跟踪查看器创建了一个DOM快照,所以你可以与之完全互动,打开devtools等。

今天的学习内容绝对的干货满满。希望大家实操练习下。

相关文章
|
6月前
|
Web App开发 Python
selenium firebug firePath xpath问题
selenium firebug firePath xpath问题
40 0
|
图形学 Windows
Unity报错之 No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager
Unity2019操作对图集进行操作编辑出错:No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager.
1270 0
Unity报错之 No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager
|
Web App开发 前端开发 JavaScript
DevTools failed to load SourceMap Could not load content for chrome-extension 解决
DevTools failed to load SourceMap Could not load content for chrome-extension 解决
266 0
Appium问题解决方案(9)- Original error: Failed to launch Appium Settings app: Condition unmet after 5090 ms
Appium问题解决方案(9)- Original error: Failed to launch Appium Settings app: Condition unmet after 5090 ms
432 0
Appium问题解决方案(9)- Original error: Failed to launch Appium Settings app: Condition unmet after 5090 ms
|
Web App开发 API Windows
一起谈.NET技术,Silverlight实例教程 - Out of Browser的Debug和Notifications窗口
  Silverlight 实例教程索引 Silverlight 实例教程 - Out of Browser开篇 Silverlight 实例教程 - Out of Browser配置,安装和卸载 Silverlight 实例教程 - Out of Browser的自定义应用 Silverligh...
1062 0
|
Web App开发 macaca Android开发