コード例 #1
0
        /// <summary>
        /// Switches into every frame in the frame chain. This is used as way to
        /// switch into nested frames (while considering scroll) in a single call.
        /// </summary>
        /// <param name="frameChain">The path to the frame to switch to.</param>
        /// <returns>The WebDriver with the switched context.</returns>
        public IWebDriver Frames(FrameChain frameChain)
        {
            FrameChain currentFrameChain = driver_.GetFrameChain();

            if (frameChain == currentFrameChain)
            {
                throw new ArgumentException("given " + nameof(frameChain) + " is the same instance as the one in the driver! Perhaps `.Clone()` is missing?");
            }

            if (FrameChain.IsSameFrameChain(currentFrameChain, frameChain))
            {
                logger_.Log(TraceLevel.Debug, Stage.General,
                            new { message = "given frame chain equals current frame chain. returning." });
                return(driver_);
            }

            logger_.Log(TraceLevel.Debug, Stage.General, new { frameChainSize = frameChain?.Count ?? 0 });
            if (currentFrameChain.Count > 0)
            {
                this.DefaultContent();
            }

            if (frameChain != null && frameChain.Count > 0)
            {
                foreach (Frame frame in frameChain)
                {
                    this.Frame(frame.Reference);
                    Frame newFrame = driver_.GetFrameChain().Peek();
                    newFrame.ScrollRootElement = frame.ScrollRootElement;
                }
            }
            return(driver_);
        }
コード例 #2
0
        /// <summary>
        /// Switches into every frame in the frame chain. This is used as way to
        /// switch into nested frames (while considering scroll) in a single call.
        /// </summary>
        /// <param name="frameChain">The path to the frame to switch to.</param>
        /// <returns>The WebDriver with the switched context.</returns>
        public IWebDriver Frames(FrameChain frameChain)
        {
            FrameChain currentFrameChain = driver_.GetFrameChain();

            if (frameChain == currentFrameChain)
            {
                throw new ArgumentException("given " + nameof(frameChain) + " is the same instance as the one in the driver! Perhaps `.Clone()` is missing?");
            }

            if (FrameChain.IsSameFrameChain(currentFrameChain, frameChain))
            {
                logger_.Verbose("given frame chain equals current frame chain. returning.");
                return(driver_);
            }

            logger_.Debug("(frameChain) - number of frames: {0}", frameChain?.Count ?? 0);
            if (currentFrameChain.Count > 0)
            {
                this.DefaultContent();
            }

            if (frameChain != null && frameChain.Count > 0)
            {
                foreach (Frame frame in frameChain)
                {
                    logger_.Debug("frame.Reference: {0}", frame.Reference);
                    this.Frame(frame.Reference);
                    logger_.Debug("frame.ScrollRootElement: {0}", frame.ScrollRootElement);
                    Frame newFrame = driver_.GetFrameChain().Peek();
                    newFrame.ScrollRootElement = frame.ScrollRootElement;
                }
                logger_.Verbose("Done switching into nested frames!");
            }
            return(driver_);
        }