You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Visual Studio 2022中调试Playwright MSTest:如何设置PWDEBUG变量?

在Visual Studio 2022中使用MSTest+Playwright时,无法通过PWDEBUG启动Playwright Inspector的问题

我在Visual Studio 2022中使用MSTest结合Playwright进行UI测试,目前遇到选择器定位的问题,想要通过Playwright DevTools或Playwright Inspector工具调试。根据Playwright官方文档的建议,设置环境变量PWDEBUG=1或PWDEBUG=console可以唤起调试工具,但官方示例都是基于VS Code或命令行执行测试的场景。

我在Visual Studio 2022的Test Explorer中尝试了两种方式,均未成功弹出调试控制台:

  • 在调试设置中添加环境变量PWDEBUG=1,无效果;
  • 创建了.runsettings文件,配置内容如下:
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
  <EnvironmentVariables>
      <PWDEBUG>1</PWDEBUG>
  </EnvironmentVariables> 
</RunSettings>

通过“测试->配置运行设置”选择该文件后,执行测试仍无法唤起调试工具。

请问我遗漏了哪些配置步骤?

内容的提问来源于stack exchange,提问作者Tony Isaac

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 06:35:30