Пример #1
0
 public static void GoToFrame(BrowserPageFrame frame)
 {
     lock (lockObject)
     {
         List <BrowserPageFrame> frameStack = new List <BrowserPageFrame>();
         GoToFrame(frame, ref frameStack);
     }
 }
Пример #2
0
        public int[] GetPath()
        {
            List <int>       path         = new List <int>();
            BrowserPageFrame currentFrame = this;

            while (currentFrame != null)
            {
                path.Add(currentFrame.Index);
                currentFrame = currentFrame.ParentFrame;
            }
            path.Reverse();
            return(path.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);
     }
 }
Пример #5
0
        public static BrowserPageFrame GetPageFramesTree()
        {
            lock (lockObject)
            {
                BrowserPageFrame root = new BrowserPageFrame()
                {
                    ChildFrames     = null,
                    Index           = -1,
                    LocatorNameOrId = "DefaultContent",
                    ParentFrame     = null,
                };

                GetDriver().SwitchTo().DefaultContent();
                root.ChildFrames = GetPageFramesTree(root);

                return(root);
            }
        }