private void LogWatcher_FileDataRecieved(
            object sender,
            FileSystemEventArgs e)
        {
            if (e.ChangeType != WatcherChangeTypes.Changed)
            {
                return;
            }

            // Check if the correct file was modified.
            var fileInfo = new FileInfo(Options.Log);

            if (fileInfo.FullName != e.FullPath)
            {
                return;
            }

            // Read & parse the last line.
            var lastLine = File.ReadLines(fileInfo.FullName).Last();
            var logEntry = SeleniumLogEntry.ParseString(lastLine);

            // Ignore exception messages.
            if (logEntry.IsException)
            {
                return;
            }

            // Check if the node is up and running.
            if (logEntry.Message.Contains("Selenium Server is up and running on port"))
            {
                var match = Regex.Match(
                    logEntry.Message,
                    @"(http[^\s]*)");

                var port = match.Groups[1];
                nodeUrl = new Uri($"http://localhost:{port}");
            }

            // Check if the node is ready.
            if (logEntry.Message.Contains("The node is registered to the hub and ready to use"))
            {
                signal.Set();
            }
        }
Exemplo n.º 2
0
        private void LogWatcher_Log(object sender, FileSystemEventArgs e)
        {
            if (e.ChangeType != WatcherChangeTypes.Changed)
            {
                return;
            }

            var fileInfo = new FileInfo(Options.Log);

            if (fileInfo.FullName != e.FullPath)
            {
                return;
            }

            // Read & parse the last line.
            var lastLine = File.ReadLines(fileInfo.FullName).Last();
            var logEntry = SeleniumLogEntry.ParseString(lastLine);

            hubLogs.Add(lastLine);
        }
Exemplo n.º 3
0
        private void LogWatcher_OutputDataRecieved(
            object sender,
            FileSystemEventArgs e)
        {
            if (e.ChangeType != WatcherChangeTypes.Changed)
            {
                return;
            }

            var fileInfo = new FileInfo(Options.Log);

            if (fileInfo.FullName != e.FullPath)
            {
                return;
            }

            // Read & parse the last line.
            var lastLine = File.ReadLines(fileInfo.FullName).Last();
            var logEntry = SeleniumLogEntry.ParseString(lastLine);

            // Ignore exception messages.
            if (logEntry.IsException)
            {
                return;
            }

            // Check if the hub is ready.
            if (lastLine.Contains("Nodes should register to"))
            {
                var match = Regex.Match(
                    lastLine,
                    @"Nodes should register to\s+(.*)");

                NodeRegisterUrl = new Uri(match.Groups[1].Value);

                signal.Set();
            }
        }
 /// <summary>
 /// Gets the logs.
 /// </summary>
 /// <returns></returns>
 /// <exception cref="NotImplementedException"></exception>
 public override IList <SeleniumLogEntry> GetLogs()
 {
     return(nodeLogs
            .Select(l => SeleniumLogEntry.ParseString(l))
            .ToList());
 }