public void RefreshFramesList()
        {
            Exception outException;
            bool      isOk = false;

            isOk = UIActions.PerformSlowOperation(
                "Operation: Refresh All Frames List",
                () =>
            {
                BrowserPageFrame rootFrame           = SwdBrowser.GetPageFramesTree();
                BrowserPageFrame[] currentPageFrames = rootFrame.ToList().ToArray();
                SwdBrowser.SwitchToDefaultContent();
                view.UpdatePageFramesList(currentPageFrames);
            },
                out outException,
                null,
                TimeSpan.FromMinutes(1)
                );

            if (!isOk)
            {
                MyLog.Error("Failed to refresh All Frames List");
                MyLog.Exception(outException);
                if (outException != null)
                {
                    throw outException;
                }
            }
        }
Exemple #2
0
        public void Get_Frames_Tree()
        {
            string[] expectedTitles = new string[]
            {
                "DefaultContent",
                "firstFrame",
                "secondFrame",
                "secondFrame.idIframeInsideSecondFrame",
                "thirdFrame",
                "thirdFrame.0"
            };


            Helper.RunDefaultBrowser();
            Helper.LoadTestFile("page_with_frames.html");


            BrowserPageFrame        rootFrame = WebSpyBrowser.GetPageFramesTree();
            List <BrowserPageFrame> allFrames = rootFrame.ToList();

            string[] actualTitles = allFrames.Select(i => i.ToString()).ToArray();

            actualTitles.Should().Equal(expectedTitles);

            WebSpyBrowser.CloseDriver();
        }
        public void ProcessCommands()
        {
            var command = WebSpyBrowser.GetNextCommand();

            if (command is GetXPathFromElement)
            {
                var getXPathCommand = command as GetXPathFromElement;
                view.UpdateVisualSearchResult(getXPathCommand.XPathValue);
            }
            else if (command is AddElement)
            {
                var addElementCommand = command as AddElement;

                SimpleFrame      simpleFrame;
                BrowserPageFrame browserPageFrame = view.getCurrentlyChosenFrame();
                if (browserPageFrame != null)
                {
                    List <string> childs = new List <string>();
                    string        parentTitle;
                    if (browserPageFrame.ParentFrame != null)
                    {
                        parentTitle = browserPageFrame.ParentFrame.GetTitle();
                    }
                    else
                    {
                        parentTitle = "none";
                    }
                    if (browserPageFrame.ChildFrames != null)
                    {
                        foreach (BrowserPageFrame b in browserPageFrame.ChildFrames)
                        {
                            childs.Add(b.GetTitle());
                        }
                    }

                    simpleFrame = new SimpleFrame(browserPageFrame.Index, browserPageFrame.LocatorNameOrId, browserPageFrame.GetTitle(), parentTitle, childs);
                }
                else
                {
                    simpleFrame = new SimpleFrame(-1, "noFrameChosen", "noFrameChosen", "noFrameChosen", null);
                }

                bool emptyHtmlId = String.IsNullOrEmpty(addElementCommand.ElementId);
                var  element     = new WebElementDefinition()
                {
                    Name        = addElementCommand.ElementCodeName,
                    HtmlId      = addElementCommand.ElementId,
                    Xpath       = addElementCommand.ElementXPath,
                    HowToSearch = (emptyHtmlId) ? LocatorSearchMethod.XPath: LocatorSearchMethod.Id,
                    Locator     = (emptyHtmlId) ? addElementCommand.ElementXPath: addElementCommand.ElementId,
                    CssSelector = addElementCommand.ElementCssSelector,
                    frame       = simpleFrame,
                    Action      = addElementCommand.Action
                };
                bool addNew = true;
                Presenters.SelectorsEditPresenter.UpdateWebElementWithAdditionalProperties(element);
                Presenters.PageObjectDefinitionPresenter.UpdatePageDefinition(element, addNew);
            }
        }
        public SwitchToPopupView(BrowserPageFrame currentFrame, WebSpyMainView parent)
        {
            InitializeComponent();

            this.parentView = parent;
            this.presenter  = Presenters.SwitchToPopupPresenter;

            presenter.InitWithView(this);
            presenter.InitWithFrame(currentFrame);
        }
 internal void SwitchToFrame(BrowserPageFrame frame)
 {
     PauseWebElementExplorerProcessing();
     try
     {
         SwdBrowser.DestroyVisualSearch();
         SwdBrowser.GoToFrame(frame);
         MyLog.Write("FRAME: Switched to frame with Index= " + frame.Index + "; and Full Name:" + frame.ToString());
     }
     finally
     {
         ResumeWebElementExplorerProcessing();
     }
 }
Exemple #6
0
        public BrowserPageFrame getCurrentlyChosenFrame()
        {
            BrowserPageFrame frame = null;
            object           item  = null;

            this.ddlFrames.Invoke((MethodInvoker) delegate()
            {
                item = ddlFrames.SelectedItem;
            }
                                  );
            if (item is BrowserPageFrame)
            {
                frame = item as BrowserPageFrame;
            }
            return(frame);
        }
Exemple #7
0
        private void btnSwitchToFrameCode_Click(object sender, EventArgs e)
        {
            BrowserPageFrame frame = ddlFrames.SelectedItem as BrowserPageFrame;

            presenter.OpenSwitchToFrameCodeHelperPopup(frame);
        }
Exemple #8
0
        private void ddlFrames_SelectedIndexChanged(object sender, EventArgs e)
        {
            BrowserPageFrame frame = ddlFrames.SelectedItem as BrowserPageFrame;

            presenter.SwitchToFrame(frame);
        }
        internal void OpenSwitchToFrameCodeHelperPopup(BrowserPageFrame currentFrame)
        {
            SwitchToPopupView popupForm = new SwitchToPopupView(currentFrame, view);

            popupForm.ShowDialog();
        }
 internal void InitWithFrame(BrowserPageFrame currentFrame)
 {
     this.currentFrame = currentFrame;
     this.view.InitLanguagesList(languagesListItems);
 }