Esempio n. 1
0
        public void HighlightWebElement(RemoteWebElement webElement)
        {
            if (webElement == null)
            {
                return;
            }
            int       X  = webElement.Location.X + (int)_toobarAutoElement.Current.BoundingRectangle.TopLeft.X;
            int       Y  = webElement.Location.Y + (int)_toobarAutoElement.Current.BoundingRectangle.TopLeft.Y + (int)_toobarAutoElement.Current.BoundingRectangle.Height;
            Rectangle rc = new Rectangle(X, Y, webElement.Size.Width, webElement.Size.Height);

            UIAHighlight.HighlightRect(rc);
        }
Esempio n. 2
0
        private void HighlightObjectThread(object param)
        {
            try
            {
                TestObjectNurse nurseObject = param as TestObjectNurse;
                if (nurseObject == null)
                {
                    return;
                }

                ITestObject testObject = nurseObject.TestObject;

                SetStatusText(StringResources.LPSpy_SpyMainWindow_Identifying);


                //Check whether the WebDriver Host exist or not
                if (testObject.ControlTypeString.StartsWith("Web"))
                {
                    SETestObject seTestObject = testObject as SETestObject;
                    if (seTestObject.SEWebElement == null)
                    {
                        //look for WebPage
                        TreeNode    parentNode   = nurseObject.TreeNode;
                        ITestObject parentObject = null;


                        do
                        {
                            parentObject = TestObjectNurse.FromTreeNode(parentNode).TestObject;
                            if (parentObject.ControlTypeString.Equals("WebPage"))
                            {
                                //seTestObject = parentObject as SETestObject;
                                break;
                            }
                        }while (null != (parentNode = parentNode.Parent));

                        if (null != parentObject)
                        {
                            //check the WebDriverHost existing
                            if (null == _webDriverHost)
                            {
                                _webDriverHost = new WebDriverHost();
                                _webDriverHost.GotoUrl(parentObject.Properties[WebControlKeys.URL]);
                            }
                            else
                            {
                                _webDriverHost.SwithToURL(parentObject.Properties[WebControlKeys.URL]);
                            }
                            WebRefreshNodeTag(parentNode);
                        }
                    }

                    Rectangle rc = _webDriverHost.GetElementRectangle(seTestObject);

                    UIAHighlight.HighlightRect(rc);
                    return;
                }


                if (!UIAHighlight.SearchAndHighlight(testObject))
                {
                    MessageBox.Show(StringResources.LPSpy_SpyMainWindow_CannotFindObjectMsg);
                }
            }
            finally
            {
                SetStatusText("");
            }
        }
        private void PointToSpiedData(Point mousePoint)
        {
            try
            {
                AutomationElement clickedElement = AutomationElement.FromPoint(mousePoint);

                WebDriverHost webDriverHost = this.Tag as WebDriverHost;
                if (null != webDriverHost && clickedElement.Current.ClassName.Equals("Chrome_RenderWidgetHostHWND"))
                {
                    System.Drawing.Point point = new System.Drawing.Point((int)mousePoint.X, (int)mousePoint.Y);
                    webDriverHost.CheckWindowHandle(clickedElement);

                    // RemoteWebElement webElement = webDriverHost.FindElementByPoint(point) as RemoteWebElement;

                    /* if (SpySettings.CaptureSnapshots && null != webElement)
                     * {
                     *   //capture snapshot of clicked area
                     *   SnapshotHelper.CaptureTempSnapshot(webElement, out _token);
                     * }*/
                    //  WebUtility.GetElementScreenRect(webElement);
                    // UIAHighlight.HighlightRect( WebUtility.GetElementScreenRect(webElement));
                    //     webDriverHost.HighlightWebElement(webElement);
                    //     ConstructElementsTree(webElement);

                    /* List<RemoteWebElement> webElements = webDriverHost.GenerateElementsLineByPoint(point);
                     *
                     * TreeNodesFromAutomationElements(webElements);*/
                    System.Drawing.Rectangle    rect = System.Drawing.Rectangle.Empty;
                    List <WebElementProperties> webElementProperiesList = webDriverHost.GenerateElementPropertiesLineByPoint(point);
                    if (webElementProperiesList.Count > 0)
                    {
                        WebElementProperties webElementProperties = webElementProperiesList[webElementProperiesList.Count - 1];
                        rect = webDriverHost.GetElementRectangle(webElementProperties);
                        UIAHighlight.HighlightRect(rect);
                    }
                    TreeNodesFromWebElementProperties(webDriverHost.GenerateElementPropertiesLineByPoint(point));
                    //webDriverHost.GetElementRectangle()
                    // UIAHighlight.HighlightRect(WebUtility.GetElementScreenRect(webDriverHost.WebSelectElement));
                    if (SpySettings.CaptureSnapshots && !rect.IsEmpty)
                    {
                        //capture snapshot of clicked area

                        SnapshotHelper.CaptureTempSnapshot(rect, out _token);
                    }


                    this.objectTree.ExpandAll();
                    return;
                }



                ConstructElementsTree(clickedElement);

                _token = null;

                if (SpySettings.CaptureSnapshots)
                {
                    //capture snapshot of clicked area
                    SnapshotHelper.CaptureTempSnapshot(clickedElement, out _token);
                }
            }
            catch (ElementNotAvailableException)
            {
                //Element is no longer available, please reselect the element
                MessageBox.Show(StringResources.LPSpy_ElementNotAvailableException);
            }
        }
 public void UIAHighlight_HighlightVirtualControl()
 {
     UIAHighlight.HighlightRect(new Rect(0, 0, 100, 200), Color.Green);
 }
 public void UIAHighlight_HighlightRectangle()
 {
     UIAHighlight.HighlightRect(new Rect(0, 0, 100, 200), Color.Green);
 }