简体   繁体   中英

C# selenium target machine actively refused it only when I try to start it programmatically

I need to have my selenium standalone sever start from my code but I keep getting the "No connection could be made because the target machine actively refused" error. The server is started from a bat file and when I try to run the bat file programmatically I get the error. If I just click an the bat file manually it work no problem its only when I try to do it through my code that I get this error.

The sever version is 4.4.0

[BeforeTestRun]
public static void setUp()
{
   StreamWriter sw =new StreamWriter("file.bat");
   sw.WriteLine("java -jar selenium-server-4.4.0.jar standalone");
   sw.Dispose();
   System.Diagnostics.Process.Start("file.bat");
}

Based of what jdweng said I copied the jar into the net48 and wrote this

 ProcessStartInfo processInfo;
 Process process;

 processInfo = new ProcessStartInfo("cmd.exe", "/K java -jar selenium-server-4.4.0.jar standalone");
 processInfo.CreateNoWindow = true;
 processInfo.UseShellExecute = true;

 process = Process.Start(processInfo);

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