使用Selenium.PhantomJS.WebDriver和.Net Core

znn*_*znn 7 c# phantomjs selenium-webdriver .net-core

NuGet包Selenium.PhantomJS.WebDriver,在构建项目时,它将PhantomJS.exe复制到bin文件夹.使用经典的.Net,效果非常好.

问题是.NetCore这不起作用.我可以直接将文件添加到解决方案中,指定copyOnBuild但我想避免它.有什么建议?

谢谢.

Ber*_*ğlu 0

我想到了两种解决方法;

如果您有机会使用像CopyLocalLockFileAssemblies这样的自定义工具,您可以在 .csproj 中尝试以下操作

<PropertyGroup>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)

第二个选项:

xcopy "$(SolutionDir)packages\Selenium.PhantomJS.WebDriver.{version}\tools\phantomjs.exe" "$(TargetDir)"
Run Code Online (Sandbox Code Playgroud)

您可以将此命令放在 postbuild.txt 中。我没有尝试过,但是这些可能会起作用。