Working on c# grids

May 17, 2010 at 6:05 AM


  I'm newbie to White automation tool and i have a grid where i need to read values from the grid and click on particular row of grid. how'd i achieve doing it? Could some one get me a sample line of code to identify grid? i wrote a code like,

//edit is nothing but window name of the application that has grid.

ListView v=edit.get<ListView>(Core.UIItems.Finder(SearchCriteria.ByControllType(


// It throws a error when i compile.

May 17, 2010 at 7:44 AM


ListView v=edit.Get<ListView>(SearchCriteria.ByControllType(ControlType.DataGrid));

if the grid has a automation id use the automation Id (use UISpy or UIAVerify to see more informations about the visual tree

ListView v=edit.Get<ListView>(SearchCriteria.ByAutomationId("id"));


May 17, 2010 at 8:39 AM

Hi Throndorin,

 Thanks a lot for your response, Well when i use following statement,

ListView v = edit.Get<ListView>(SearchCriteria.ByControllType(ControlType.DataGrid));

it throws error at compile time as "SearchCriteria does not exist in this context and SearchCriteria does not exist in this context" also,

when i write ListView v = edit.Get<ListView>(  ,i'm not able to get SearchCriteria keyword in my C# editor.



Thanks in advance.


May 17, 2010 at 9:26 AM
Edited May 17, 2010 at 9:29 AM



usage White.Core.UIItems.Finder;


Note: all usages start with Core... are not longer correct if you use White 1.8 or newer. The Namespace has changed to White.Core.....


if you use VisualStudio, maybe try Resharper extension, it is a very nice tool show, compile errors before compile. (like eclipse for Java). And has a lot of other nice features.


May 17, 2010 at 9:36 AM
Edited May 17, 2010 at 11:44 AM



Thanks a lot for guidance, i'm using White 0.17 and  when i try include "using White.Core" Core does not comes as option even though i have that White.Core dll as reference. So i tried including "using Core.UIItems.Finder" and i'm able to get searchcriteria like as you mentioned,


ListView v=edit.Get<ListView>(SearchCriteria.ByControllType but not able to get (ControlType.datagrid), may be it is because of dll version problems?
and the error is like "Core.UIItems.Finder does not contain definition for ControlType".

Thanks in advance.





May 17, 2010 at 11:36 AM

ok in 1.7 the Namespace Core is correct :)


did you reference UIAutomation?


ControlType is not part of the White DLL's?




May 17, 2010 at 11:49 AM

Oh thanks for information, i didn't get any file as UIAutomation to make its reference, i once again checked into Core folder too but that file doesn't exist in my Core folder. Is it because of i'm using old version of Core ? And how to get it to make reference ?

May 17, 2010 at 1:46 PM
Edited May 17, 2010 at 1:47 PM

UIAutomation is part of the .Net Framework, after installation you will find it in the global assembly cache.

so in visual studio you can reference the same way as System and so on.


White is a framework of UIAutomation


May 18, 2010 at 5:18 AM
Well i'm sorry i'm still not able to see that UIAutomation dll to reference, and not even getting the keyword ControllType.Datagrid. Well let me know the process to add reference to UIAutomation, i tried adding it as usually i do with other but i'm not able to find it. Thanks in advance.
May 18, 2010 at 12:06 PM

Has you installed.Net Framework 3.5??

after that open your test solution in Visual Studio and add reference to UIAutomationTypes


see more here (msdn)






May 18, 2010 at 12:39 PM


Yes i understood what you are suggesting , i have installed .net framework 3.5 SP1, i checked my GAC in windows and found files UIAUtiomationClient,UIAUtiomationClientSideProvider,UIAUtiomationProvider, UIAUtiomationTypes. I'm not able to find System.Windows.UIAutomation in GAC either in my Visual C# 2005 Express edition. And one more thing is that when i tried making reference to afore stated files through brows option in my C# editor , they throw error. So could you please tell me which option are you going through your visual studio editor and where do you find the UIAutomation dll to make reference, I mean each and every step. I have doubt if i'm missing something.




Thanks in advance.

May 18, 2010 at 4:34 PM


mmh strange, can you have a look in this samle

Have a look at the references, can you build it. (only change the references to the white dll's)

The sample use White 1.7 so you should not have problems to build it,.




May 19, 2010 at 10:50 AM
Hi Throndorin, Thanks for your guidance and help but sorry to say , my problem not been fixed. Don't know what is wrong or i'm missing. I am just not able to find name space System.Windows.Automation. I found these three files UIAUtiomationClient,UIAUtiomationClientSideProvider,UIAUtiomationProvider, UIAUtiomationTypes. under c:\Windows\Assembly and nothing happens when i make reference through brows option io C# editor. Let me do more research on if i'm missing any environment settings like dll's etc. Anyways i thank you once again for sparing your precious time for me. Thanks and regards.
May 20, 2010 at 6:51 AM

Oh Wow ! thanks a lot for your guidance i finally found that file under c:\Program Files\Reference Assembly\. I was always looking into C:\Windows\Assembly. Thank you for sparing your precious time for me and i'll come back if get further doubts.



Thanks you.

May 25, 2010 at 7:29 AM

Hi ,

can any one help me , i am unable to find the datagrid values present in the window, i tested with listview as well as Table ,iam not able to find any controls inside the datagrid, there is any other way to find the datagrid

because the values in datagrid is in runtime .


If any solution is there can u help me pls






May 25, 2010 at 7:34 AM

Hi hari kutty

have you tryied UISpy or UIAVerify to see what elements are included in the datagrid?

you can also use the operation LogStructure to see which elements are part of the datagrid.


Which White version did you use?

is the application under test a WinForm or a WPF /Silverlight application?




May 25, 2010 at 8:49 AM



 I am also facing the same problem, my application is developed using C# and silverlight.


ListView l = MainWindow.Get<ListView>(SearchCriteria.ByControlType(ControlType.DataGrid)); // throws when i try to iterate through ListView l.


And I am using White 2.0, I don't know how to do UISpy or UIAVerify, Could you please put more light on it for me?


Thanks and regards.

May 25, 2010 at 9:13 AM
Edited May 25, 2010 at 9:16 AM


get UIAVerify from Codeplex (Link) or UISpy (part of Windows SDK read here)

The tools are only needed to get informations about elements which can be used for UIAutomation and so with White.


open the application to test and to the part of the application where the ListView (or each other element you need informations about) is located.

open one of the above tools (I prefer UIAVerify)

enable hover mode in UIAVerify (in UISpy it is enabled by default)

press STRG and click to the element you need informations about


UIAVerify or UISpy will now display the visual tree, and all elements which are visible for UIAutomation and so usable for White.


I can't give detailed help for Silverlight, only for general things, I test WPF or WinForm.






May 26, 2010 at 5:49 AM



I have got that UIAVerify and i did check with the component I am trying to work with, It's being identified as Table, but I am not able to get keyword Table in my editor, I have made reference to Core.UIItems as well with Windows Automation dll. I even have an automation id for that control. Could you tell me what I am missing?


Thanks and regards.

May 26, 2010 at 6:25 AM




using White.Core.UIItems.TableItems;




May 26, 2010 at 7:31 AM



Below is the code i'm using to identify table,

 try   {

     Table t = MainWindow.Get<Table>(SearchCriteria.ByAutomationId("scacGrid"));                

    foreach (TableRow r in t.Rows)                



 }            }            

catch (Exception e)            {                 System.Windows.Forms.MessageBox.Show(e.ToString());            }


The exception says "Object not set to an instance of object"

May 26, 2010 at 7:45 AM
Edited May 26, 2010 at 7:47 AM

so t is null?


can you try the following?



AutomationElement element = MainWindow.GetElement(SearchCriteria.ByAutomationId("scacGrid"));



is the element null?


if not try



Table t = new Table(element, MainWindow.ActionListener);



or is the row null?


and r.ToString() throws the exception?



Jun 23, 2010 at 11:23 AM










<font size="2">


</font>// White.Core.UIItems.TableItems.Table xDatagrid1 = ActiveWindow.Get<White.Core.UIItems.TableItems.Table>(SearchCriteria.ByControlType(System.Windows.Automation.ControlType.DataGrid));


<font size="2">


</font>Table xDatagrid = ActiveWindow.Get<White.Core.UIItems.TableItems.Table>(value);


<font size="2">


</font>//ActiveWindow.Get<White.Core.UIItems.TableItems.Table>(SearchCriteria.ByText(value)).Row("0", "Port Name");


<font size="2">


</font>if (xDatagrid != null)


<font size="2">


</font>//xDatagrid.Rows foreach stmt


<font size="2">


</font>foreach (White.Core.UIItems.TableItems.TableRow row in rowss)



rowss[0].Cells[0].Value =

<font size="2">





<font size="2">


</font>// row.Cells[0].Value = "PREC701";



<font size="2">


</font>TableRows rowss = xDatagrid.Rows;


rows count =0

but still the grid has value



pls help me if u have any solutions for this