コード例 #1
0
 public static void Maximize()
 {
     lock (lockObject)
     {
         WebSpyBrowser.GetDriver().Manage().Window.Maximize();
     }
 }
コード例 #2
0
 public static IWebElement[] GetAllFrameElements()
 {
     lock (lockObject)
     {
         var driver = WebSpyBrowser.GetDriver();
         var frames = driver.FindElements(By.CssSelector(@"frame, iframe"));
         return(frames.ToArray());
     }
 }
コード例 #3
0
        public static List <BrowserPageFrame> GetPageFramesTree(BrowserPageFrame parent)
        {
            lock (lockObject)
            {
                List <BrowserPageFrame> children = new List <BrowserPageFrame>();

                //
                var driver = WebSpyBrowser.GetDriver();

                var allFramesOnThePage = GetAllFrameElements();
                for (var i = 0; i < allFramesOnThePage.Length; i++)
                {
                    var frameElement = allFramesOnThePage[i];

                    BrowserPageFrame frameItem = new BrowserPageFrame()
                    {
                        ChildFrames     = null,
                        Index           = i,
                        LocatorNameOrId = null,
                        ParentFrame     = parent,
                    };

                    string elementId   = frameElement.GetAttribute("id");
                    string elementName = frameElement.GetAttribute("name");

                    if (!String.IsNullOrEmpty(elementName))
                    {
                        frameItem.LocatorNameOrId = elementName;
                    }
                    else if (!String.IsNullOrEmpty(elementId))
                    {
                        frameItem.LocatorNameOrId = elementId;
                    }
                    else
                    {
                        frameItem.LocatorNameOrId = String.Empty;
                    }

                    GetDriver().SwitchTo().Frame(i);
                    frameItem.ChildFrames = GetPageFramesTree(frameItem);

                    List <BrowserPageFrame> frameStack = new List <BrowserPageFrame>();
                    WebSpyBrowser.GoToFrame(parent, ref frameStack);

                    children.Add(frameItem);
                }

                return(children);
            }
        }
コード例 #4
0
 private static void GoToFrame(BrowserPageFrame frame, ref List <BrowserPageFrame> frameStack)
 {
     if (frame.ParentFrame == null)
     {
         WebSpyBrowser.GetDriver().SwitchTo().DefaultContent();
         frameStack.Reverse();
         foreach (var frameItem in frameStack)
         {
             WebSpyBrowser.GetDriver().SwitchTo().Frame(frameItem.Index);
         }
         return;
     }
     else
     {
         frameStack.Add(frame);
         GoToFrame(frame.ParentFrame, ref frameStack);
     }
 }