示例#1
0
        private static HtmlNode GetOriginElement(ConsoleArgs consoleArgs)
        {
            var document = new HtmlDocument();

            document.Load(consoleArgs.OriginalFilePath);

            var element = document.GetElementbyId(consoleArgs.TargetElementId);

            if (element == null)
            {
                throw new Exception("Element not found");
            }
            return(element);
        }
示例#2
0
        static void Main(string[] args)
        {
            try
            {
                var consoleArgs = new ConsoleArgs(args);
                if (!consoleArgs.IsValid)
                {
                    Console.WriteLine($"Invalid parameters: {nameof(consoleArgs.OriginalFilePath)} - {consoleArgs.OriginalFilePath};" +
                                      $" {nameof(consoleArgs.DiffFilePath)} - {consoleArgs.DiffFilePath};" +
                                      $" {nameof(consoleArgs.TargetElementId)} - {consoleArgs.TargetElementId}");
                    return;
                }

                var element = GetOriginElement(consoleArgs);
                if (element == null)
                {
                    Console.WriteLine("Can't find origin element");
                }
                else
                {
                    Console.WriteLine("Origin Element: ");
                    ShowElement(element);
                }

                var diffDocument = new HtmlDocument();
                diffDocument.Load(consoleArgs.DiffFilePath);
                var diffElement = diffDocument.GetElementbyId(consoleArgs.TargetElementId) ?? GetDiffElement(diffDocument, element);

                if (diffElement == null)
                {
                    Console.WriteLine("Can't find diff element.");
                }
                else
                {
                    Console.WriteLine("Diff element: ");
                    ShowElement(diffElement);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error trying to find element by id, Message: {0}", ex.Message);
            }
        }