我找不到有关 Microsoft.Playwright 包的任何详细信息。 是否可以在没有 NodeJS 的情况下运行它?如果是,如何测试 firefox、chromium、edge、webkit 和 Chrome? 如果没有安装浏览器,如何指定二进制路径?是否可以通过 runsetting xml 文件来完成?
谢谢你!
我尝试了这个,但它不起作用,因为 BrowserExecutablePath 不存在:
string chromiumPath = "/path/to/chromium/binary";
string firefoxPath = "/path/to/firefox/binary";
string webkitPath = "/path/to/webkit/binary";
string edgePath = "/path/to/chromium/binary";
string chromePath = "/path/to/firefox/binary";
var launchOptions = new BrowserTypeLaunchOptions
{
// Specify the paths to the browser binaries
ChromiumExecutablePath = chromiumPath,
FirefoxExecutablePath = firefoxPath,
WebkitExecutablePath = webkitPath,
EdgeExecutablePath = edgePath,
ChromeExecutablePath = chromePath
};
在这个文件设置中,我不知道是否可以做到
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<EnvironmentVariables>
<!-- List of environment variables we want to set-->
<OG_BDD_TESTS_MERCHANT_SURCHARGING_DEV_BROWSER>Chromium</OG_BDD_TESTS_MERCHANT_SURCHARGING_DEV_BROWSER>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>
我发现 Microsoft.Playwright 包能够在不使用 NodeJS 的情况下启动浏览器。但需要安装浏览器。