private void WillSwitchToFrame_(IWebElement targetFrame)
        {
            ArgumentGuard.NotNull(targetFrame, nameof(targetFrame));
            if (!(targetFrame is EyesRemoteWebElement eyesFrame))
            {
                eyesFrame = new EyesRemoteWebElement(logger_, driver_, targetFrame);
            }

            Point pl = targetFrame.Location;
            Size  ds = targetFrame.Size;

            SizeAndBorders     sizeAndBorders = eyesFrame.SizeAndBorders;
            RectangularMargins borderWidths   = sizeAndBorders.Borders;
            Size clientSize = sizeAndBorders.Size;

            Rectangle bounds = eyesFrame.GetClientBounds();

            Point contentLocation = new Point(bounds.X + borderWidths.Left, bounds.Y + borderWidths.Top);
            //Point originalLocation = ScrollPositionProvider.GetCurrentPosition(jsExecutor_, driver_.FindElement(By.TagName("html")));
            Point originalLocation = eyesFrame.ScrollPosition;

            Frame frame = new Frame(logger_, targetFrame,
                                    contentLocation,
                                    new Size(ds.Width, ds.Height),
                                    clientSize,
                                    originalLocation,
                                    bounds,
                                    borderWidths,
                                    jsExecutor_);

            driver_.GetFrameChain().Push(frame);
        }
Exemple #2
0
        private void WillSwitchToFrame_(IWebElement targetFrame)
        {
            ArgumentGuard.NotNull(targetFrame, nameof(targetFrame));
            if (!(targetFrame is EyesRemoteWebElement eyesFrame))
            {
                eyesFrame = new EyesRemoteWebElement(logger_, driver_, targetFrame);
            }

            Size ds = targetFrame.Size;

            SizeAndBorders     sizeAndBorders = eyesFrame.SizeAndBorders;
            RectangularMargins borderWidths   = sizeAndBorders.Borders;
            Size clientSize = sizeAndBorders.Size;

            Rectangle bounds = eyesFrame.GetClientBounds();

            Point contentLocation  = new Point(bounds.X + borderWidths.Left, bounds.Y + borderWidths.Top);
            Point originalLocation = eyesFrame.ScrollPosition;

            Frame frame = new Frame(logger_, targetFrame,
                                    contentLocation,
                                    new Size(ds.Width, ds.Height),
                                    clientSize,
                                    originalLocation,
                                    bounds,
                                    borderWidths,
                                    jsExecutor_);
            var activeElementBeforeSwitch = targetLocator_.ActiveElement();

            targetLocator_.Frame(targetFrame);
            var activeElementAfterSwitch = targetLocator_.ActiveElement();

            if (!activeElementAfterSwitch.Equals(activeElementBeforeSwitch))
            {
                driver_.GetFrameChain().Push(frame);
            }
            else
            {
                throw new Exception("Failed switching to frame.");
            }
        }