簡體   English   中英

以編程方式啟動用於Selenium測試的.NET Core Web應用程序

[英]Programmatically start a .NET Core web app for Selenium testing

我目前正在嘗試在Core Web應用程序上設置一些UI測試,但是我無法啟動Web應用程序。 從Web應用程序目錄直接使用命令行“dotnet run”工作。 當我在執行測試之前嘗試使用Process來運行它時,問題就出現了。

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

有沒有人在遇到類似的問題之前和/或設法解決它? 我可能會誤用Process

UseShellExecute將UseShellExecute添加到我的StartInfo並將其設置為false使其工作:

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

UseShellExecute的默認值為true,但它類似於運行cmd dotnet run而不是dotnet run ,這是我需要的。

試試這個

 ProcessStartInfo Startinfo = new ProcessStartInfo();
 Startinfo.FileName = "D:\\TFS\\QA\\SH_LoadTest\\SH_LoadTest\\bin\\Debug\\SH_LoadTest.exe";
 StartInfo.Arguments="Your Arguements";
                Process pro = Process.Start(Startinfo);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM