以编程方式启动用于Selenium测试的.NET Core Web应用程序

Cod*_*ger 6 c# selenium selenium-webdriver .net-core

我目前正在尝试在Core Web应用程序上设置一些UI测试,但是我无法启动Web应用程序.从Web应用程序目录直接使用命令行"dotnet run"工作.当我在执行测试之前尝试使用Process来运行它时,问题就出现了.

    var process = new Process
    {
        StartInfo =
        {
            FileName = "dotnet",
            Arguments = "run",
            WorkingDirectory = applicationPath
        }
    };
    process.Start();
Run Code Online (Sandbox Code Playgroud)

有没有人在遇到类似的问题之前和/或设法解决它?我可能会误用Process.

Cod*_*ger 6

UseShellExecute转而添加到我的StartInfo并将其设置为false使其工作:

var process = new Process
{
    StartInfo =
    {
        FileName = "dotnet",
        Arguments = "run",
        UseShellExecute = false,
        WorkingDirectory = applicationPath
    }
};
process.Start();
Run Code Online (Sandbox Code Playgroud)

默认UseShellExecute值为true,但它类似于运行cmd dotnet run而不是dotnet run我需要的.