简体   繁体   中英

Programmatically start a .NET Core web app for Selenium testing

I am currently trying to setup some UI tests on a Core web app, however I am not able to get the web app started. Using the command line directly with "dotnet run" from the web app directory works. The problem comes when I try to use Process to run it before executing my tests nothing happens.

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

Has anyone been confronted to a similar issue before and/or managed to solve it? I may be misusing Process .

Turns that adding UseShellExecute to my StartInfo and setting it to false made it work:

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

The default for UseShellExecute is true but it would be similar to running cmd dotnet run instead of dotnet run which is what I needed.

Try this

 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM