Represents the options available from the command line.
Beispiel #1
0
        /// <summary>
        /// The main entry point into the application.
        /// </summary>
        /// <param name="args">The set of arguments passed in on the command line.</param>
        public static void Main(string[] args)
        {
            Options commandLineOptions = new Options(args);
            logger = new ConsoleLogger(commandLineOptions.LoggingLevel);
            if (commandLineOptions.ReserveUrl)
            {
                bool urlReserved = ReserveUrl(commandLineOptions.UrlToReserve, true);
                if (!urlReserved)
                {
                    Environment.ExitCode = 1;
                }
            }
            else
            {
                LogVersionDetails(commandLineOptions);
                userName = commandLineOptions.UserName;
                password = commandLineOptions.Password;
                ignoreRemoteShutdown = commandLineOptions.IgnoreRemoteShutdown;
                httpServer = new RemoteWebDriverServer(commandLineOptions.Port, "wd/hub/", logger);
                httpServer.ShutdownRequested += new EventHandler(OnRemoteServerShutdownRequested);
                bool urlReservationExists = CheckForUrlReservation(commandLineOptions);
                if (urlReservationExists)
                {
                    httpServer.StartListening();
                    logger.Log(string.Format(CultureInfo.InvariantCulture, "Server started. RemoteWebDriver instances connect to http://<this machine name>:{0}/wd/hub/", commandLineOptions.Port), LogLevel.Info);
                    if (!string.IsNullOrEmpty(commandLineOptions.HubLocation))
                    {
                        httpServer.RegisterWithHub(commandLineOptions.HubLocation);
                    }

                    Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);
                    while (continueRunning)
                    {
                        System.Threading.Thread.Sleep(100);
                    }
                }
            }
        }
Beispiel #2
0
        private static bool CheckForUrlReservation(Options commandLineOptions)
        {
            bool urlReservationExists = true;
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                urlReservationExists = false;
                ReadOnlyCollection<string> urlReservations = HttpApi.GetReservedUrlList();
                foreach (string reservation in urlReservations)
                {
                    if (reservation == httpServer.ListenerPrefix)
                    {
                        urlReservationExists = true;
                        break;
                    }
                }

                if (!urlReservationExists)
                {
                    logger.Log(string.Format(CultureInfo.InvariantCulture, "URL reservation for '{0}' does not exist. Reserving URL.", httpServer.ListenerPrefix));
                    urlReservationExists = ReserveUrl(httpServer.ListenerPrefix, commandLineOptions.CurrentUserIsAdmin);
                }
            }

            return urlReservationExists;
        }
Beispiel #3
0
 private static void LogVersionDetails(Options commandLineOptions)
 {
     string serverVersion = commandLineOptions.ServerVersion;
     string operatingSystemVersion = commandLineOptions.OSVersion;
     logger.Log(serverVersion);
     logger.Log(".NET runtime version: " + Environment.Version.ToString());
     logger.Log("OS version: " + operatingSystemVersion);
 }