Esempio n. 1
0
        public void ProcessCommands()
        {
            var command = SwdBrowser.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,
                };
                bool addNew = true;
                Presenters.SelectorsEditPresenter.UpdateWebElementWithAdditionalProperties(element);
                Presenters.PageObjectDefinitionPresenter.UpdatePageDefinition(element, addNew);
            }
        }
        public void ProcessCommands()
        {
            var command = SwdBrowser.GetNextCommand();

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

                var element = new WebElementDefinition()
                {
                    Name        = addElementCommand.ElementCodeName,
                    HowToSearch = LocatorSearchMethod.XPath,
                    Locator     = addElementCommand.ElementXPath,
                };
                bool addNew = true;
                Presenters.SelectorsEditPresenter.UpdateWebElementWithAdditionalProperties(element);
                Presenters.PageObjectDefinitionPresenter.UpdatePageDefinition(element, addNew);
            }
        }