Beispiel #1
0
 public FakeComparisonResult(ElementChangeResult[] changedResult = null, ElementAddRemoveResult[] addedResult = null, 
     ElementAddRemoveResult[] removedResult = null, int unchangedItems = 0, decimal cssPercent = 0, decimal textPercent = 0, 
     decimal overallPercent = 0, PixelResult pixelResult = null, HtmlResult htmlResult = null, string htmlDiff = null)
 {
     _changedResult  = changedResult;
     _addedResult    = addedResult;
     _removedResult  = removedResult;
     _unchangedItems = unchangedItems;
     _cssPercent     = cssPercent;
     _textPercent    = textPercent;
     _overallPercent = overallPercent;
     _pixelResult    = pixelResult;
     _htmlResult     = htmlResult;
     _htmlDiff       = htmlDiff;
 }
Beispiel #2
0
        /// <summary>
        /// Returns information about the given element.
        /// </summary>
        /// <param name="pageScreenshot">The screenshot of the page containing the element.</param>
        /// <param name="scrapedElement">The element.</param>
        /// <param name="page">The page containing the element.</param>
        /// <returns>An ElementAddRemoveResult object.</returns>
        private ElementAddRemoveResult GetElementData(Image pageScreenshot, ScrapedElement scrapedElement, Scrape page)
        {
            var originalA = ImageUtil.CropImage(pageScreenshot, scrapedElement.LocationOnScreenshot);
            var regionA   = ImageUtil.GetClippedRegion(scrapedElement.LocationOnScreenshot, page.Elements.Select(e => e.LocationOnScreenshot));
            var clippedA  = ImageUtil.GetClippedImage(new Size(scrapedElement.LocationOnScreenshot.Width, scrapedElement.LocationOnScreenshot.Height), originalA, regionA);
            var imageMask = ImageUtil.DrawRegionAsMasks(new Size(scrapedElement.LocationOnScreenshot.Width, scrapedElement.LocationOnScreenshot.Height), regionA, originalA, _ia);

            var add = new ElementAddRemoveResult
            {
                Attributes   = scrapedElement.Attributes,
                Html         = scrapedElement.Html,
                Text         = scrapedElement.Text,
                Location     = scrapedElement.LocationOnScreenshot,
                Tag          = scrapedElement.Tag,
                Image        = originalA,
                ImageClipped = clippedA,
                ImageMask    = imageMask
            };

            return add;
        }