[英]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. 我目前正在尝试在Core Web应用程序上设置一些UI测试,但是我无法启动Web应用程序。 Using the command line directly with "dotnet run" from the web app directory works.
从Web应用程序目录直接使用命令行“dotnet run”工作。 The problem comes when I try to use Process to run it before executing my tests nothing happens.
当我在执行测试之前尝试使用Process来运行它时,问题就出现了。
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
. 我可能会误用
Process
。
Turns that adding UseShellExecute
to my StartInfo and setting it to false
made it work: UseShellExecute
将UseShellExecute添加到我的StartInfo并将其设置为false
使其工作:
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. UseShellExecute
的默认值为true,但它类似于运行cmd dotnet run
而不是dotnet run
,这是我需要的。
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.