TestStack.White 如何在 WinForm 应用程序中单击位于文档中的超链接

TestStack.White How to click on Hyperlink Located in a Document in WinForm Application

我正在尝试使用 TestStack.White 框架在 1 个应用程序中进行一些自动化测试,但我找不到关于如何单击位于一个文档中的超链接的解决方案。 document.logstructure() :

AutomationId: linkTexts
ControlType: ControlType.Document
Name: Perform an action on event#LinkId=1
      from devices/recording server/management server#LinkId=2

HelpText: 
Bounding rectangle: 354,563,570,151
ClassName: WindowsForms10.RichEdit20W.app.0.ca490a_r12_ad1
IsOffScreen: False
FrameworkId: WinForm
ProcessId: 6816

System.Windows.Automation.ScrollPattern
System.Windows.Automation.TextPattern

用户界面间谍: UISpy view

以及超链接图片: Picture of hyperlink located in app

谢谢!

经过几天的搜索,我能找到的最佳解决方案是:

         {
            ...  
            //Get document container
            var document = _modalWindow.Get(SearchCriteria.ByAutomationId(Config.DocumentRulesEvent));

            // Get document's bounding Rectangle
            string rightCorner = document.Bounds.Right.ToString();
            string leftCorner = document.Bounds.Left.ToString();
            string topCorner = document.Bounds.Top.ToString();
            string bottomCorner = document.Bounds.Bottom.ToString();
            // Hardcoded percent of x and y
            int percentX = 22;
            int percentY = 7;


            GetCoordinatesFromBoundingRectangle(rightCorner, leftCorner, topCorner, bottomCorner, percentX, percentY);
        }

        public void GetCoordinatesFromBoundingRectangle(string rightCorner, string leftCorner, string topCorner, string bottomCorner, int percentX, int percentY)
        {

            // transform strings to integre    
            int a = Int32.Parse(rightCorner);
            int b = Int32.Parse(leftCorner);
            int c = Int32.Parse(topCorner);
            int d = Int32.Parse(bottomCorner);

            // Calculate X from AB segment
            int x = (a - b) * percentX;
            x = x / 100;
            x = b + x;

            //Calculate Y from CD segment
            int y = (d - c) * percentY;
            y = y / 100;
            y = c + y;

            ClickOnPoint(x, y);


        }

        // Method that moves mouse to x and y and click
        public void ClickOnPoint(int x, int y)
        {
            var pointClick = new System.Windows.Point(x, y);
            Mouse.Instance.Click(MouseButton.Left, pointClick);
        }