我使用 Playwright 和 .NET 绑定创建了一些测试。
[OneTimeSetUp]
public async Task OneTimeSetUp()
{
random = new Random();
var playwright = await Playwright.CreateAsync();
browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
{
Headless = false
});
context = await browser.NewContextAsync();
page = await context.NewPageAsync();
}
在运行测试之前,我已经运行
npx playwright install
在运行测试之前。上述命令的结果是浏览器安装在路径 C:\Users\username\AppData\Local\ms-playwright
但是,在运行测试时,会引发错误:
OneTimeSetUp: Microsoft.Playwright.PlaywrightException : Executable doesn't exist at C:\Users\11033414\AppData\Local\ms-playwright\chromium-907428\chrome-win\chrome.exe
所以看起来剧作家想要使用其他版本的浏览器而不是安装的浏览器。如何让 Playwright 指向安装的浏览器的正确版本?