public void Start()
 {
     try
     {
         var nodePort = _launcherDataProvider.GetFirstAvailablePort(Type.Node);
         if (nodePort == default(int))
         {
             _progress.Report("Could not start node due to non-availability of free ports. Please try again later when at least one instance is shut down.");
         }
         var    ieVersion          = SysOperations.GetIeVersion();
         var    defaultNodeCommand = _GetDefaultNodeCommand(_hubPort.ToString(CultureInfo.InvariantCulture), nodePort.ToString(CultureInfo.InvariantCulture));
         var    nodeBrowsers       = _BuildBrowsersNodeCommand(_nodeOptions, ieVersion);
         string nodeCommand        = String.Format("{0}{1}", defaultNodeCommand, nodeBrowsers);
         _nodeProcess = ProcessHelper.StartProcess(String.Format(@"{0}\java.exe", SysOperations.GetJavaPath(_progress)), _progress, nodeCommand, false);
         Thread.Sleep(1000);
         if (_nodeProcess != null && _nodeProcess.HasExited == false)
         {
             _progress.Report(
                 string.Concat(
                     "Node started. Please check the opened command window and/or browser window to ensure it started successfully. For logs look in C:\\Selenium\\_Logs folder.",
                     Environment.NewLine));
             //remove double quotes from _nodeLog before storing
             _launcherDataProvider.AddProcess(Type.Node, _nodeLog.Trim('\"'), _nodeProcess.Id, nodePort);
         }
         else
         {
             _progress.Report(
                 string.Concat(
                     "There was a problem starting the node. Please check that all required files exist in C:\\Selenium folder, expecially 'selenium-server-standalone.jar'",
                     Environment.NewLine));
         }
     }
     catch (Exception e)
     {
         _progress.Report(string.Format("Could not start node. {0}{1}", e, Environment.NewLine));
     }
 }
示例#2
0
        public int Start()
        {
            var port = default(int);

            try
            {
                port = _launcherDataProvider.GetFirstAvailablePort(Type.Hub);
                if (port == default(int))
                {
                    _progress.Report("Could not start hub due to non-availability of free ports. Please try again later when at least one instance is shut down.");
                    return(port);
                }
                var hubCommand = _GetDefaultHubCommand(port.ToString(CultureInfo.InvariantCulture));

                _hubProcess = ProcessHelper.StartProcess(String.Format(@"{0}\java.exe", SysOperations.GetJavaPath(_progress)), _progress, hubCommand, false);
                Thread.Sleep(1000);
                if (_hubProcess != null && _hubProcess.HasExited == false)
                {
                    _progress.Report(string.Concat(
                                         "Hub started. Please check the opened command window and/or browser window to ensure it started successfully. For logs look in C:\\Selenium\\_Logs folder.",
                                         Environment.NewLine));
                    //remove double quotes from _hubLog before storing
                    _launcherDataProvider.AddProcess(Type.Hub, _hubLog.Trim('\"'), _hubProcess.Id, port);
                    return(port);
                }
                _progress.Report(
                    string.Concat(
                        "There was a problem starting the hub. Please check that all required files exist in C:\\Selenium folder, expecially 'selenium-server-standalone.jar'",
                        Environment.NewLine));
            }
            catch (Exception e)
            {
                _progress.Report(string.Format("Could not start hub. {0}{1}", e, Environment.NewLine));
            }
            return(port);
        }