public IWebDriver Frame(IWebElement frameElement)
 {
     logger_.Debug("EyesTargetLocator.frame(element)");
     WillSwitchToFrame_(frameElement);
     logger_.Debug("Switching to frame...");
     targetLocator_.Frame(frameElement);
     logger_.Verbose("Done!");
     return(driver_);
 }
 /// <summary>
 /// This method Navigate control to iframe
 /// </summary>
 /// <param name="frameid">FrameId</param>
 public static void NavigateToIFrame(string frameid)
 {
     Thread.Sleep(2000);
     currentframe = driver.SwitchTo();
     currentframe.Frame(frameid);
     log.Info("Moved to IFrame");
 }
        public IWebDriver FramesDoScroll(FrameChain frameChain)
        {
            logger_.Verbose("EyesTargetLocator.framesDoScroll(frameChain)");
            ITargetLocator targetLocator = driver_.SwitchTo();

            targetLocator.DefaultContent();
            IPositionProvider scrollProvider = new ScrollPositionProvider(logger_, jsExecutor_, driver_.Eyes.GetCurrentFrameScrollRootElement());

            defaultContentPositionMemento_ = scrollProvider.GetState();
            foreach (Frame frame in frameChain)
            {
                logger_.Verbose("Scrolling by parent scroll position...");
                Point frameLocation = frame.Location;
                scrollProvider.SetPosition(frameLocation);
                logger_.Verbose("Done! Switching to frame...");
                targetLocator.Frame(frame.Reference);
                Frame newFrame = driver_.GetFrameChain().Peek();
                newFrame.ScrollRootElement            = frame.ScrollRootElement;
                newFrame.ScrollRootElementInnerBounds = frame.ScrollRootElementInnerBounds;
                logger_.Verbose("Done!");
            }

            logger_.Verbose("Done switching into nested frames!");
            return(driver_);
        }
Beispiel #4
0
        /// <summary>
        /// Switches into every frame in the list. This is used as way to switch into nested frames in a single call.
        /// </summary>
        /// <param name="framesPath">The path to the frame to check. This is a list of frame names/IDs (where each frame is nested in the previous frame).</param>
        /// <returns>The WebDriver with the switched context.</returns>
        public IWebDriver Frames(string[] framesPath)
        {
            logger_.Log(TraceLevel.Debug, Stage.General, StageType.Called);
            ITargetLocator targetLocator = driver_.SwitchTo();

            foreach (string frameNameOrId in framesPath)
            {
                targetLocator.Frame(frameNameOrId);
            }
            return(driver_);
        }
Beispiel #5
0
        public void QQLogin()
        {
            dynamic type             = (new UnitTest1()).GetType();
            string  currentDirectory = Path.GetDirectoryName(type.Assembly.Location);
            var     driver           = new ChromeDriver(currentDirectory);

            driver.Url = "https://qzone.qq.com/";
            try
            {
                //切换语法有两种,一种是根据索引切换,另外一种根据iframe名称切换
                //这里我们使用name切换
                ITargetLocator tagetLocator = driver.SwitchTo();
                //tagetLocator.Frame(1);  //frame index.
                tagetLocator.Frame("login_frame");  //frame frame name.
                var switchLogin = driver.FindElementByCssSelector("#switcher_plogin");
                switchLogin.Click();
                var userName = driver.FindElementByXPath("//*[@id='u']");
                //这里的userName就是用户名的文本框
                //设置用户名的值
                userName.SendKeys("123456");
                var pwd = driver.FindElementByXPath("//*[@id='p']");
                pwd.SendKeys("********");
                var btnLogin = driver.FindElementByXPath("//*[@id='login_button']");
                //这里是判断登录按钮是否可见,可以不写,直接调用click方法
                if (btnLogin != null && btnLogin.Displayed == true)
                {
                    btnLogin.Click();
                }
                System.Threading.Thread.Sleep(3000);
                //*[@id="menuContainer"]/div/ul/li[5]/a
                var msgDom = driver.FindElementByXPath("//*[@id='menuContainer']/div/ul/li[5]/a");
                if (msgDom != null && msgDom.Displayed == true)
                {
                    msgDom.Click();
                }
                //页面跳转,切换到说说页面的说说列表Iframe
                ITargetLocator t = driver.SwitchTo();
                //这里我们换一种获取元素方法,直接使用css获取
                //xpath //*[@id="app_container"]/iframe
                //css #app_container > iframe
                IWebElement frame = driver.FindElementByCssSelector("#app_container > iframe");
                t.Frame(frame);
                //定义说说集合
                var dataAll = new List <MessageInfo>();
                //第一页开始,pageIndex 默认0
                //定义汉字方法为了直观描述功能,不要在意这些细节
                说说内容获取(driver, dataAll, 0);
            }
            finally
            {
                driver.Quit();
            }
        }
        /// <summary>
        /// Switches into every frame in the list. This is used as way to switch into nested frames in a single call.
        /// </summary>
        /// <param name="framesPath">The path to the frame to check. This is a list of frame names/IDs (where each frame is nested in the previous frame).</param>
        /// <returns>The WebDriver with the switched context.</returns>
        public IWebDriver Frames(string[] framesPath)
        {
            logger_.Verbose("(framesPath)");
            ITargetLocator targetLocator = driver_.SwitchTo();

            foreach (string frameNameOrId in framesPath)
            {
                logger_.Debug("Switching to frame '{0}'...", frameNameOrId);
                targetLocator.Frame(frameNameOrId);
            }
            logger_.Verbose("Done switching into nested frames!");
            return(driver_);
        }
Beispiel #7
0
        public WebDriverInstance Frame(object frameArg)
        {
            if (frameArg == null || frameArg == Null.Value || frameArg == Undefined.Value)
            {
                return(new WebDriverInstance(this.Engine.Object.InstancePrototype, m_targetLocator.Frame(String.Empty)));
            }

            if (frameArg is WebElementInstance)
            {
                var webElement = (frameArg as WebElementInstance).WebElement;
                return(new WebDriverInstance(this.Engine.Object.InstancePrototype, m_targetLocator.Frame(webElement)));
            }

            if (TypeUtilities.IsNumeric(frameArg))
            {
                var value = TypeConverter.ToInteger(frameArg);
                return(new WebDriverInstance(this.Engine.Object.InstancePrototype, m_targetLocator.Frame(value)));
            }

            var strValue = TypeConverter.ToString(frameArg);

            return(new WebDriverInstance(this.Engine.Object.InstancePrototype, m_targetLocator.Frame(strValue)));
        }
        private void SwitchToFrame_(IWebElement frameElement,
                                    ISeleniumFrameCheckTarget frameTarget, Configuration config, List <FrameState> frameStates)
        {
            ITargetLocator switchTo = driver_.SwitchTo();

            switchTo.Frame(frameElement);
            IWebElement rootElement = SeleniumEyes.GetScrollRootElementFromSREContainer(frameTarget, driver_);
            Frame       frame       = driver_.GetFrameChain().Peek();

            frame.ScrollRootElement = rootElement;
            SaveCurrentFrameState_(frameStates, driver_, rootElement);
            TryHideScrollbarsInFrame(config, driver_, rootElement);
            frame.ScrollRootElementInnerBounds = EyesRemoteWebElement.GetClientBoundsWithoutBorders(rootElement, driver_, logger_);
        }
Beispiel #9
0
 public static void ParentFrame(Logger logger, ITargetLocator targetLocator, FrameChain frameChainToParent)
 {
     logger.Log(TraceLevel.Debug, Stage.General, StageType.Called);
     try
     {
         targetLocator.ParentFrame();
     }
     catch
     {
         targetLocator.DefaultContent();
         foreach (Frame frame in frameChainToParent)
         {
             targetLocator.Frame(frame.Reference);
         }
     }
 }
 public static void ParentFrame(Logger logger, ITargetLocator targetLocator, FrameChain frameChainToParent)
 {
     logger.Debug("enter (static)");
     try
     {
         targetLocator.ParentFrame();
     }
     catch
     {
         targetLocator.DefaultContent();
         foreach (Frame frame in frameChainToParent)
         {
             targetLocator.Frame(frame.Reference);
         }
     }
 }
Beispiel #11
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.");
            }
        }
Beispiel #12
0
        public IWebDriver FramesDoScroll(FrameChain frameChain)
        {
            logger_.Log(TraceLevel.Debug, Stage.General, StageType.Called);
            ITargetLocator targetLocator = driver_.SwitchTo();

            targetLocator.DefaultContent();
            IPositionProvider scrollProvider = new ScrollPositionProvider(logger_, jsExecutor_, driver_.Eyes.GetCurrentFrameScrollRootElement());

            defaultContentPositionMemento_ = scrollProvider.GetState();
            foreach (Frame frame in frameChain)
            {
                Point frameLocation = frame.Location;
                scrollProvider.SetPosition(frameLocation);
                targetLocator.Frame(frame.Reference);
                Frame newFrame = driver_.GetFrameChain().Peek();
                newFrame.ScrollRootElement            = frame.ScrollRootElement;
                newFrame.ScrollRootElementInnerBounds = frame.ScrollRootElementInnerBounds;
            }

            return(driver_);
        }
Beispiel #13
0
 public IWebDriver Frame(int frameIndex)
 {
     lock (m_lock) { return(new WebDriver(locator.Frame(frameIndex), m_lock)); }
 }
Beispiel #14
0
 public IWebDriver Frame(int frameIndex)
 {
     return(_targetLocator.Frame(frameIndex));
 }
 public IWebDriverWrapper Frame(IWebElement frameElement)
 {
     return(_targetLocator.Frame(frameElement).ToWrapper());
 }
Beispiel #16
0
        public void SwitchFrame(int frameIndex)
        {
            ITargetLocator target = driver.SwitchTo();

            target.Frame(frameIndex);
        }
Beispiel #17
0
        public void SwitchFrame(string frameName)
        {
            ITargetLocator target = driver.SwitchTo();

            target.Frame(frameName);
        }