Is it possible to automate WinForm controls (such as CheckBox and GcTextBox) wi

Posted by: eyone on 26 October 2023, 3:48 pm EST

    • Post Options:
    • Link

    Posted 26 October 2023, 3:48 pm EST - Updated 26 October 2023, 3:50 pm EST

    We’re using teststack.white for our UI automation testing, so have a need to automate the various SPREAD controls in our application.

    Can this be done?

  • Posted 26 October 2023, 3:50 pm EST

    In the following source code, can we retrieve each control within SPREAD’s “sprGrid” that includes rows and columns (e.g., CheckBox, GcTextBox, GcDatetime…)?

    If so, could you provide a sample code?

    mainWindow = AutomationElement.RootElement.FindFirst(
                    TreeScope.Children, new PropertyCondition(
                        AutomationElement.NameProperty, "WindowName"));
    
    var sprGrid = mainWindow.FindFirst(TreeScope.Descendants,
                    new PropertyCondition(AutomationElement.AutomationIdProperty, "sprGrid"));
  • Posted 30 October 2023, 12:07 am EST

    Hi Erina,

    We are in discussions with the developers regarding this requirement. [Internal Tracking ID: SPNET-34760]

    We will update you on this as soon as we hear back from them on this.

    Thanks & Regards,

    Aastha

  • Posted 30 October 2023, 3:06 pm EST - Updated 31 October 2023, 11:08 am EST

    Hello, Aastha.

    Thank you for your reply. I’m looking forward to it.

    Erina

    p.s.

    I’d like to provide additional information about the SPREAD I’m using.

    Here are the details:

    SPREAD for Windows Forms 12.0J

    File Version: 12.0.4510.2012

    Assembly Version: 12.0.4510.2012

    I’m interested in using the GridPattern to access various controls within the “sprGrid” in SPREAD, which includes rows and columns of controls like CheckBox, GcTextBox, and GcDatetime.

  • Posted 31 October 2023, 4:40 pm EST

    Hi Erina,

    As per the information provided by the developers, Spread does not support UI automation yet. Therefore, we are sorry to inform you that you cannot fetch the elements for UI automation.

    Since the implementation of this feature requires a lot of resources, the developers have not provided an ETA for this.

    We will keep you updated on this as they inform us further.

    Thanks & Regards,

    Aastha

  • Posted 31 October 2023, 7:07 pm EST

    Hi, Aastha.

    Thank you for your prompt response.

    I would like to conduct a UI test to input values into cells within SPREAD.

    Please provide guidance on how to achieve this without using UI Automation.

    If there is an alternative method, please also provide sample codes.

    Thank you in advance.

    Erina

  • Posted 1 November 2023, 11:03 pm EST

    Hi Erina,

    As per the information provided by the developers, Spread provides a limited API to get the rectangle of element like cell. You can consider using them and implement your own UI testing.

    The developers have provided us with a sample code snippet to move mouse to the center of cell B2:

          var cellB2Rect = fpSpread1.GetCellRectangle(0, 0, 1, 1);  //relative to Spread control
          System.Drawing.Point b2CenterPt = fpSpread1.PointToScreen(cellB2Rect.Location); //relative to screen
          b2CenterPt.Offset(cellB2Rect.Width / 2, cellB2Rect.Height / 2);
          Cursor.Position = b2CenterPt;

    Kindly let us know if you need any further help.

    Thanks & Regards,

    Aastha

  • Posted 6 November 2023, 3:55 pm EST - Updated 6 November 2023, 4:00 pm EST

    Hi, Aastha.

    "Is there a way to retrieve ‘fpSpread1’ when using the snippet you provided earlier?

    I was planning to use the following code, but I’m running into the error below.

    If you have an alternative method to access controls on the screen that can be effectively used with the snippet you provided, please let me know.

    Error Message:

    CS1061

    ‘UITest’ does not contain a definition for ‘Controls,’ and no accessible extension method ‘Controls’ that accepts the first argument of type ‘UITest’ was found.

    Please ensure that necessary using directives or assembly references are not missing.

    Thank you in advance.

    Erina

  • Posted 6 November 2023, 4:00 pm EST

    [code]Application application = Application.Launch(“YourApp.exe”);

    TestStack.White.UIItems.WindowItems.Window window = application.GetWindow(“Screen name”);

    var fpSpread = window.Get(“YourSpreadsheetName”);

    if (fpSpread != null)

    {

                var cellB2Rect = fpSpread.GetCellRectangle(0, 0, 1, 1); 
                System.Drawing.Point b2CenterPt = new System.Drawing.Point(cellB2Rect.Left + cellB2Rect.Width / 2, cellB2Rect.Top + cellB2Rect.Height / 2);
    
                System.Windows.Forms.Cursor.Position = b2CenterPt;
            }
            else
            {
                Console.WriteLine("can not find fpSpread ");
            }
    

    [/code]

  • Posted 7 November 2023, 5:33 pm EST

    Hi Erina,

    Thanks for providing the code snippet.

    >‘UITest’ does not contain a definition for ‘Controls,’ and no accessible extension method ‘Controls’ that accepts the first argument of type ‘UITest’ was found.

    Unfortunately, we could not find the error to be associated to the above code snippet. We request you provide us a small sample application that shows this error with implementation. This will help us analyze the issue in a better way for further investigation.

    Thanks & Regards,

    Aastha

  • Posted 21 December 2023, 11:24 am EST

    Hi, Aastha.

    You mentioned that SPREAD does not yet support UIAutomation.

    Could you please recommend any other automated testing tools that are compatible with SPREAD?

  • Posted 21 December 2023, 5:37 pm EST

    Hi Erina,

    We are sorry to inform you that Spread does not support automation testing. Since supporting automation testing must be done from the control (Spread) but not testing tools, therefore there is no automated testing tool that can be used for this purpose.

    Thanks & Regards,

    Aastha

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels