KryptonDataGridView cell values for testing automation?

Hello I have an application that uses Krypton toolkit controls extensively. I have a grid with values loaded from a database. I am trying to write a test automation C# application using TestStack White. I am having trouble grabbing values from those cells on that DataGridView. 

Here is a snippet if it helps. I am unable to get any rows or columns returned. Please offer any assistance for using either TestStack or Microsoft's Automation UI. I cannot use "Coded UI" because of the cost for VS Enterprise. So I need a way to do this without Coded UI. Any assistance at all would be nice.


var pointsKryptonDataGridViewControl = window.Get(SearchCriteria.ByAutomationId("pointsKryptonDataGridView"));
            var testTable = window.Get<Table>(SearchCriteria.ByAutomationId("pointsKryptonDataGridView")).AutomationElement;

            var headerLine = testTable.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Header));
            var cacheRequest = new CacheRequest { AutomationElementMode = AutomationElementMode.Full, TreeScope = TreeScope.Children };
            cacheRequest.Add(AutomationElement.NameProperty);
            cacheRequest.Add(ValuePattern.Pattern);
            cacheRequest.Push();
            var gridLines = testTable.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom));
            cacheRequest.Pop();

            Console.WriteLine(headerLine.Count + " columns");
            Console.WriteLine(gridLines.Count + " rows");

3 Replies

PM Piruthiviraj Malaimelraj Syncfusion Team May 25, 2018 12:32 PM UTC

Hi Derek Ross, 

Thanks for your interest in Syncfusion products. 

We have analyzed the reported scenario and we are little bit unclear with this scenario. Could you please provide us with the simple nUnit test method written for Syncfusion GridControl in your test project? and way of configuring TestStack White automation utility with GridControl application. It would be more helpful for us to provide the better solution at the earliest.  

Regards, 
Piruthiviraj 



DR Derek Ross May 25, 2018 03:49 PM UTC

I do not have an NUnit test. I am using just TestStack White. I am using the following code to grab the window:

ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.FileName = @"C:\Projects\Program location"
            Application application = Application.Launch(startInfo);

            Window window = application.GetWindow(SearchCriteria.ByText("App Name"),
            TestStack.White.Factory.InitializeOption.WithCache);

Then, on my application's (not the testing app but actual app) solution, I used the variable name for the control, the datagridview, which is "pointsKryptonDataGridView" and so that's the name I use for this piece of code in my testing solution:

var pointsKryptonDataGridViewControl = window.Get(SearchCriteria.ByAutomationId("pointsKryptonDataGridView"));
            var testTable = window.Get<Table>(SearchCriteria.ByAutomationId("pointsKryptonDataGridView")).AutomationElement;

In your response "and way of configuring TestStack White automation utility with GridControl application" that is basically what I am trying to figure out. Now I am using the KryptonDataGridView from v4.0.30319. If that helps. I am unable to inspect this with Inspect or Spy++. So I need to know how to automate testing this gridview without using Coded UI.


PM Piruthiviraj Malaimelraj Syncfusion Team May 28, 2018 12:05 PM UTC

Hi Derek, 

Thanks for your update. 

Please confirm us that whether you are using Syncfusion GridControl in your project or not since you are using KryptonDataGridView control. If you are using Syncfusion Grid, provide the Syncfusion EssentialStudio build version details and code customization that you have tried with our GridControl , not KryptonDataGridView. So that we can analyze it further and provide the better solution at the earliest. 

Regards, 
Piruthiviraj

Loader.
Up arrow icon