为了运行UI测试,我试图在我的部署目标计算机上安装剧作家。
# Install the CLI once.
dotnet tool install --global Microsoft.Playwright.CLI
playwright install但是,当使用剧作家CLI (包括剧作家安装)时,我得到:
无法使用剧作家找到项目。确保C:\users\myuser中存在项目或解决方案,或者使用-p提供另一条路径。
如何在vm上安装剧作家?
编辑:
不幸的是,为剧作家设计的.NET nuget软件包设计得不太好。虽然API很棒,但部署却是噩梦。
不仅无法在部署服务器上使用CLI安装浏览器,而且包还将3x NodeJS运行时(200 it )添加到项目和所有引用它的项目中。
防止这些文件被发布是非常重要的,而且您的构建工件可以轻松地增长到每个构建的1GB!
您无法配置到NodeJS或剧作家本身的路径。
您可以在这里投票解决这个问题:https://github.com/microsoft/playwright-dotnet/issues/1850
发布于 2021-11-13 18:03:32
您需要在包含playwright install的文件夹中执行csproj,或者使用-p指定项目文件。
# Create project
dotnet new console -n PlaywrightDemo
cd PlaywrightDemo
# Install dependencies, build project and download necessary browsers.
dotnet add package Microsoft.Playwright
dotnet build
playwright install有关更多细节,请参见文档:https://playwright.dev/dotnet/docs/intro#first-project
还可以使用以下方法从代码中安装浏览器:
using Microsoft.Playwright;
var exitCode = Microsoft.Playwright.Program.Main(new[] { "install" });更多细节:https://www.meziantou.net/distributing-applications-that-depend-on-microsoft-playwright.htm
发布于 2022-07-18 06:02:11
为我工作是..。在管道中构建解决方案之前,可以在管道中使用.net核心的还原命令重新恢复剧作家包,并在构建管道后使用powershell安装剧作者驱动程序,如下所示
选择FilePath类型
脚本路径: YourProjectName\bin\Debug\netcoreapp3.1\playwright.ps1
https://stackoverflow.com/questions/69956848
复制相似问题