Esempio n. 1
0
        private void dgNodesSelected_SelectionChanged(object sender, EventArgs e)
        {
            if (dgNodesSelected.SelectedRows.Count > 0)
            {
                int    rowIndex = dgNodesSelected.SelectedRows[0].Index;
                MyNode node     = _nodesSelected[rowIndex];
                ShowScreenShot(node);

                tbScriptEventName.Text    = node.EventName;
                rbScriptSendClick.Checked = node.SendClick;
                rbScriptSendKeys.Checked  = node.SendKeys;
                tbScriptSendKeysText.Text = node.SendKeysText;
                tbScriptWaitSeconds.Text  = node.WaitElementBySecond.ToString();

                showSelectedNodesProperties(MyNode.ExtractSelectors(node));

                tbNodeSelectedDetails.Text = node.Element.ToString();
            }
        }
Esempio n. 2
0
        private void dgNodes_SelectionChanged(object sender, EventArgs e)
        {
            tbKeyAttributes.Text = "";
            tbNodeDetails.Text   = "";

            if (dgNodes.SelectedRows.Count > 0)
            {
                int rowIndex = dgNodes.SelectedRows[0].Index;

                MyNode node = _nodes[rowIndex];

                tbNodeDetails.Text = node.Element.ToString();

                if (node.KeyAttributes.Count > 0)
                {
                    tbKeyAttributes.ForeColor = Color.Green;
                    tbNodeDetails.ForeColor   = Color.Green;
                    foreach (var k in node.KeyAttributes)
                    {
                        tbKeyAttributes.Text = k.Key + "=" + "\"" + k.Value + "\"" + Environment.NewLine;
                    }
                }
                else
                {
                    tbKeyAttributes.ForeColor = Color.Red;
                    tbNodeDetails.ForeColor   = Color.Red;
                    tbKeyAttributes.Text      = "No attributes";
                }


                showSelectedNodesProperties(MyNode.ExtractSelectors(node));


                ShowScreenShot(node);
            }
        }
Esempio n. 3
0
        private void RunTest(MyNode n, DeviceConfig deviceConfig)
        {
            IWebElement element = null;

            #region update screenshot
            MyNode.TpGUIScreenshot guiScreenshot = new MyNode.TpGUIScreenshot();

            Screenshot   screenshot = ((ITakesScreenshot)_driver).GetScreenshot();
            MemoryStream ms         = new MemoryStream(screenshot.AsByteArray);
            guiScreenshot.Screenshot = Image.FromStream(ms);
            guiScreenshot.Width      = _driver.Manage().Window.Size.Width;
            guiScreenshot.Height     = _driver.Manage().Window.Size.Height;

            n.GUIScreenshot = guiScreenshot;
            #endregion

            DateTime timeStart = DateTime.Now;

            if (n.WaitElementBySecond > 0)
            {
                System.Threading.Thread.Sleep(n.WaitElementBySecond * 1000);
            }

            List <XPathSelector> xpaths = new List <XPathSelector>();

            xpaths = MyNode.ExtractSelectors(n);


            xpaths = MyNode.OrderBySelectorInOrder(xpaths);

            foreach (XPathSelector selector in xpaths)
            {
                //if (selector.Type != XPathSelector.XPathType.AncestorIndex)
                //    continue;

                try
                {
                    if (n.Platform == "Android" && selector.XPathForAndroid != "")
                    {
                        element = _driver.FindElementByXPath(selector.XPathForAndroid);
                    }
                    else if (n.Platform == "iOS" && selector.XPathForIOS != "")
                    {
                        element = _driver.FindElementByXPath(selector.XPathForIOS);
                    }
                }
                catch
                {
                    continue;
                }

                if (element != null)
                {
                    break;
                }
            }


            if (element != null)
            {
                try
                {
                    if (n.SendClick)
                    {
                        element.Click();
                    }
                    else if (n.SendKeys)
                    {
                        element.Click();
                        element.Clear();
                        element.SendKeys(n.SendKeysText);

                        if (n.Platform == "Android")
                        {
                            _driver.HideKeyboard();
                        }
                        else if (n.Platform == "iOS")
                        {
                            _driver.FindElementByXPath("//*[@name='Hide keyboard']").Click();
                        }
                    }
                }
                catch (Exception ex)
                {
                    RegisterLog("[Run Test] Error - " + ex.Message);
                }

                TimeSpan ts = DateTime.Now.Subtract(timeStart);


                #region Extract status of executation

                //Screenshot screenshotExec = ((ITakesScreenshot)_driver).GetScreenshot();
                //MemoryStream msExec = new MemoryStream(screenshotExec.AsByteArray);

                //MyNode.TpGUIScreenshot guiScreenshotExec = new MyNode.TpGUIScreenshot()
                //{
                //    Screenshot = Image.FromStream(msExec),
                //    Width = _driver.Manage().Window.Size.Width,
                //    Height = _driver.Manage().Window.Size.Height
                //};

                //XDocument xml = XDocument.Parse(_driver.PageSource);

                //n.ExecutationState = new MyNode.TpExecutationState()
                //{
                //    Executed = true,
                //    GUIScreenshot = guiScreenshotExec,
                //    Xml = xml,
                //    Runtime = ts.TotalSeconds
                //};

                #region Reprocess RunTime total for all nodes/events

                double runTimeTotal = 0;
                foreach (MyNode nAux in deviceConfig.Events)
                {
                    runTimeTotal += nAux.ExecutationState.Runtime;
                }

                //update RuntimePercent
                foreach (MyNode nAux in deviceConfig.Events)
                {
                    nAux.ExecutationState.RuntimePercent = (100 * nAux.ExecutationState.Runtime) / runTimeTotal;
                }


                #endregion


                #endregion
            }
        }
Esempio n. 4
0
        private void btnSummaryApplicable_Click(object sender, EventArgs e)
        {
            int absolutePath       = 0;
            int identifyAttributes = 0;
            int crossPlatform      = 0;
            int elementType        = 0;
            int ancestorIndex      = 0;
            int ancestorAttributes = 0;


            foreach (var node in _nodesSelected)
            {
                List <XPathSelector> selectors = MyNode.ExtractSelectors(node);

                foreach (var s in selectors)
                {
                    string xPath = "";

                    if (_deviceConfig.PlatformName == "Android")
                    {
                        xPath = s.XPathForAndroid;
                    }
                    else if (_deviceConfig.PlatformName == "iOS")
                    {
                        xPath = s.XPathForIOS;
                    }

                    if (s.Type == XPathSelector.XPathType.AbsolutePath && xPath != "")
                    {
                        absolutePath++;
                    }
                    else if (s.Type == XPathSelector.XPathType.IdentifyAttributes && xPath != "")
                    {
                        identifyAttributes++;
                    }
                    else if (s.Type == XPathSelector.XPathType.CrossPlatform && xPath != "")
                    {
                        crossPlatform++;
                    }
                    else if (s.Type == XPathSelector.XPathType.ElementType && xPath != "")
                    {
                        elementType++;
                    }
                    else if (s.Type == XPathSelector.XPathType.AncestorIndex && xPath != "")
                    {
                        ancestorIndex++;
                    }
                    else if (s.Type == XPathSelector.XPathType.AncestorAttributes && xPath != "")
                    {
                        ancestorAttributes++;
                    }
                }

                tbAbsolutePath.Text       = "Applicable: " + absolutePath.ToString() + "    NOT Applicable: " + (_nodesSelected.Count - absolutePath).ToString();
                tbIdentifyAttributes.Text = "Applicable: " + identifyAttributes.ToString() + "    NOT Applicable: " + (_nodesSelected.Count - identifyAttributes).ToString();
                tbCrossPlatform.Text      = "Applicable: " + crossPlatform.ToString() + "    NOT Applicable: " + (_nodesSelected.Count - crossPlatform).ToString();
                tbElementType.Text        = "Applicable: " + elementType.ToString() + "    NOT Applicable: " + (_nodesSelected.Count - elementType).ToString();
                tbAncestorIndex.Text      = "Applicable: " + ancestorIndex.ToString() + "    NOT Applicable: " + (_nodesSelected.Count - ancestorIndex).ToString();
                tbAncestorAttributes.Text = "Applicable: " + ancestorAttributes.ToString() + "    NOT Applicable: " + (_nodesSelected.Count - ancestorAttributes).ToString();


                tbAbsolutePath.ForeColor       = Color.Blue;
                tbIdentifyAttributes.ForeColor = Color.Blue;
                tbCrossPlatform.ForeColor      = Color.Blue;
                tbElementType.ForeColor        = Color.Blue;
                tbAncestorIndex.ForeColor      = Color.Blue;
                tbAncestorAttributes.ForeColor = Color.Blue;
            }
        }