Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

How to Invoke an Application in Selenium WebDriver

We can use Process to invoke external application in Java. 

Process p = Runtime.getRuntime().exec("myFile.exe");
 p.waitFor();

 Use System.Diagnostics.Process in C# to invoke external application. For example, in this code snippet below, we invoke multiple instances of Selenium RC Server starting the port number 4446. 

 Code Snippet

  1. public void StartSeleniumServer( int j)
  2.         {
  3.             System.Diagnostics.Process process = new System.Diagnostics.Process();
  4.                 System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
  5.                 startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
  6.                 startInfo.FileName = "cmd.exe";
  7.                 startInfo.Arguments = "/C java -jar " + "C:\\Selenium_Server\\" + "seleniumserverstandalone2320.jar -port " + Convert.ToString(4446 + j) + "";
  8.                 process.StartInfo = startInfo;
  9.                 process.Start();
  10.                 }