vscode自动化playwright
时间: 2023-11-13 11:53:23 浏览: 192
vscode自动配置
5星 · 资源好评率100%
可以使用 VSCode 自带的调试功能来自动化 Playwright 测试。先在 VSCode 中安装 Playwright 插件,然后在项目根目录下创建一个 `.vscode` 文件夹,并在里面创建一个 `launch.json` 文件。在 `launch.json` 中添加以下配置:
```
{
"version": "0.2.0",
"configurations": [
{
"name": "Playwright",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "test:playwright"],
"env": {
"PLAYWRIGHT_BROWSERS_PATH": "/usr/bin",
"HEADLESS": "false"
}
}
]
}
```
其中,`PLAYWRIGHT_BROWSERS_PATH` 指定了 Playwright 下载浏览器的路径,可以根据自己的实际情况修改。`HEADLESS` 可以配置是否使用无头模式运行测试。
然后在 VSCode 的 Debug 界面中选择 `Playwright` 配置,并点击 `Run` 按钮,即可自动运行测试。
阅读全文