Esempio n. 1
0
        private Region GetRegionInScreenshot_(Region region, Bitmap image, double pixelRatio)
        {
            if (region.IsSizeEmpty)
            {
                return(region);
            }

            logger_.Verbose("Creating screenshot object...");
            // We need the screenshot to be able to convert the region to screenshot coordinates.
            EyesScreenshot screenshot = getEyesScreenshot_(image);

            logger_.Verbose("Getting region in screenshot...");

            // Region regionInScreenshot = screenshot.convertRegionLocation(regionProvider.getRegion(), regionProvider.getCoordinatesType(), CoordinatesType.SCREENSHOT_AS_IS);
            Region regionInScreenshot = screenshot.GetIntersectedRegion(region, CoordinatesTypeEnum.SCREENSHOT_AS_IS);

            Size scaledImageSize = new Size((int)Math.Round(image.Width / pixelRatio), (int)Math.Round(image.Height / pixelRatio));

            regionInScreenshot = sizeAdjuster_.AdjustRegion(regionInScreenshot, scaledImageSize);

            logger_.Verbose("Region in screenshot: {0}", regionInScreenshot);
            regionInScreenshot = regionInScreenshot.Scale(pixelRatio);
            logger_.Verbose("Scaled region: {0}", regionInScreenshot);

            regionInScreenshot = regionPositionCompensation_.CompensateRegionPosition(regionInScreenshot, pixelRatio);

            // Handling a specific case where the region is actually larger than
            // the screenshot (e.g., when body width/height are set to 100%, and
            // an internal div is set to value which is larger than the viewport).
            regionInScreenshot.Intersect(new Region(0, 0, image.Width, image.Height));
            logger_.Verbose("Region after intersect: {0}", regionInScreenshot);
            return(regionInScreenshot);
        }
        public IList <FloatingMatchSettings> GetRegions(IEyesBase eyesBase, IEyesScreenshot screenshot)
        {
            ReadOnlyCollection <IWebElement> elements = ((Eyes)eyesBase).GetDriver().FindElements(selector_);
            IList <FloatingMatchSettings>    retVal   = new List <FloatingMatchSettings>();
            double scaleRatio = ((Eyes)eyesBase).GetScaleRatioForRegions();

            foreach (IWebElement element in elements)
            {
                Region r = new Region(element.Location, element.Size);
                r = r.Scale(scaleRatio);
                Point pTag = screenshot.ConvertLocation(r.Location, CoordinatesTypeEnum.CONTEXT_RELATIVE, CoordinatesTypeEnum.SCREENSHOT_AS_IS);

                retVal.Add(
                    new FloatingMatchSettings()
                {
                    Left           = pTag.X,
                    Top            = pTag.Y,
                    Width          = r.Width,
                    Height         = r.Height,
                    MaxLeftOffset  = maxLeftOffset_,
                    MaxUpOffset    = maxUpOffset_,
                    MaxRightOffset = maxRightOffset_,
                    MaxDownOffset  = maxDownOffset_
                }
                    );
            }
            return(retVal);
        }
        public IList <AccessibilityRegionByRectangle> GetRegions(IEyesBase eyesBase, IEyesScreenshot screenshot)
        {
            double scaleRatio = ((Eyes)eyesBase).GetScaleRatioForRegions();
            Region r          = new Region(element_.Location, element_.Size);

            r = r.Scale(scaleRatio);
            Point pTag = screenshot.ConvertLocation(r.Location, CoordinatesTypeEnum.CONTEXT_RELATIVE, CoordinatesTypeEnum.SCREENSHOT_AS_IS);

            return(new AccessibilityRegionByRectangle[] {
                new AccessibilityRegionByRectangle(new Rectangle(pTag, r.Size), regionType_)
            });
        }
Esempio n. 4
0
        public IList <IMutableRegion> GetRegions(EyesBase eyesBase, EyesScreenshot screenshot)
        {
            IWebElement element    = element_;
            double      scaleRatio = ((Eyes)eyesBase).GetScaleRatioForRegions();
            Region      r          = new Region(element.Location, element.Size);

            r = r.Scale(scaleRatio);
            eyesBase.Logger.Verbose("screenshot: {0}", screenshot);
            Point pTag = screenshot.ConvertLocation(r.Location, CoordinatesTypeEnum.CONTEXT_RELATIVE, CoordinatesTypeEnum.SCREENSHOT_AS_IS);

            return(new MutableRegion[] { new MutableRegion(pTag.X, pTag.Y, r.Width, r.Height) });
        }
Esempio n. 5
0
        public IList <AccessibilityRegionByRectangle> GetRegions(IEyesBase eyesBase, IEyesScreenshot screenshot)
        {
            ReadOnlyCollection <IWebElement>       elements = ((Eyes)eyesBase).GetDriver().FindElements(selector_);
            IList <AccessibilityRegionByRectangle> retVal   = new List <AccessibilityRegionByRectangle>();
            double scaleRatio = ((Eyes)eyesBase).GetScaleRatioForRegions();

            foreach (IWebElement element in elements)
            {
                Region r = new Region(element.Location, element.Size);
                r = r.Scale(scaleRatio);
                Point pTag = screenshot.ConvertLocation(r.Location, CoordinatesTypeEnum.CONTEXT_RELATIVE, CoordinatesTypeEnum.SCREENSHOT_AS_IS);
                retVal.Add(new AccessibilityRegionByRectangle(new Rectangle(pTag, r.Size), regionType_));
            }
            return(retVal);
        }
        public IList <IMutableRegion> GetRegions(IEyesBase eyesBase, IEyesScreenshot screenshot)
        {
            IWebDriver driver = ((Eyes)eyesBase).GetDriver();
            ReadOnlyCollection <IWebElement> elements       = driver.FindElements(selector_);
            IList <IMutableRegion>           mutableRegions = new List <IMutableRegion>();
            double scaleRatio = ((Eyes)eyesBase).GetScaleRatioForRegions();

            foreach (IWebElement element in elements)
            {
                Region r = new Region(element.Location, element.Size);
                r = r.Scale(scaleRatio);
                Point pTag = screenshot.ConvertLocation(r.Location, CoordinatesTypeEnum.CONTEXT_RELATIVE, CoordinatesTypeEnum.SCREENSHOT_AS_IS);
                mutableRegions.Add(new MutableRegion(pTag.X, pTag.Y, r.Width, r.Height));
            }
            return(mutableRegions);
        }
        public IList <FloatingMatchSettings> GetRegions(EyesBase eyesBase, EyesScreenshot screenshot)
        {
            double scaleRatio = ((Eyes)eyesBase).GetScaleRatioForRegions();
            Region r          = new Region(element_.Location, element_.Size);

            r = r.Scale(scaleRatio);
            Point pTag = screenshot.ConvertLocation(r.Location, CoordinatesTypeEnum.CONTEXT_RELATIVE, CoordinatesTypeEnum.SCREENSHOT_AS_IS);

            return(new FloatingMatchSettings[] {
                new FloatingMatchSettings()
                {
                    Left = pTag.X,
                    Top = pTag.Y,
                    Width = r.Width,
                    Height = r.Height,
                    MaxLeftOffset = maxLeftOffset_,
                    MaxUpOffset = maxUpOffset_,
                    MaxRightOffset = maxRightOffset_,
                    MaxDownOffset = maxDownOffset_
                }
            });
        }