Finding the colour of a cell in an Infragistics Grid.

Ask general questions here.
devenb
Posts: 24
Joined: Mon Mar 09, 2009 11:50 am
Location: Bracknell, UK

Finding the colour of a cell in an Infragistics Grid.

Post by devenb » Fri Sep 25, 2009 10:10 am

Hi,

In one of our Test Cases I need to check whether one of the cells in a row of an Infragistics grid changes its color. It is like the cell is highlighted. Is there any way to check this since there are no attributes for the cell to check for the color change.

Regards,
Deven B.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Finding the colour of a cell in an Infragistics Grid.

Post by Support Team » Mon Sep 28, 2009 8:52 am

Hi devenb,
first of all there`s no full support for Infragistic Controls to get all properties directly(only information provided from MSAA).

It seems to me that the color information in Infragistics UltraGrid cells is in the 'Appearance' Property of the UltraGrid cell class. So we can use InvokeRemotely to get the information we need.

some links for InvokeRemotely:
http://www.ranorex.com/blog/transfering ... et-control
http://www.ranorex.com/forum/post3244.h ... tely#p3244


Sample Code
e.g. get the BackColor property from the active cell in an Infragistics Ultragrid (v9.1)

create your delegate:
static object GetBackgroundColor(System.Windows.Forms.Control control, object input)
{
    Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid = (control as Infragistics.Win.UltraWinGrid.UltraGrid);
	Color backColor = ultraGrid.ActiveCell.Appearance.BackColor;

	return backColor;
}
Get the UltraGrid Control (use Ranorex Spy) and cast it to Ranorex.Control. Call InvokeRemotely:
Ranorex.Control elementUltraGrid1 = "/form[@controlname='Form1']/element[@controlname='UltraGrid1']";
Color backColor = (Color)elementUltraGrid1.InvokeRemotely(GetBackgroundColor);
Best regards,
Christian
Ranorex Support Team
.
Image

devenb
Posts: 24
Joined: Mon Mar 09, 2009 11:50 am
Location: Bracknell, UK

Re: Finding the colour of a cell in an Infragistics Grid.

Post by devenb » Mon Oct 05, 2009 11:46 am

Thanks for the reply.
For getting this done do I need to install Infragistics on my machine and include it in the project workspace?

Regards,
Deven B.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Finding the colour of a cell in an Infragistics Grid.

Post by Support Team » Mon Oct 05, 2009 12:23 pm

Typically it`s not necessary to install the infagistics setup. For calling 'Invoke Remotely' you have to add the related assemblies to your testing application. (i.e. Infragistics2.Shared, Infragistics2.WinUltraGrid, Infagistics2.Win).

Regards,
Christian
Ranorex Support Team
.
Image

devenb
Posts: 24
Joined: Mon Mar 09, 2009 11:50 am
Location: Bracknell, UK

Re: Finding the colour of a cell in an Infragistics Grid.

Post by devenb » Mon Oct 05, 2009 1:02 pm

Support Team wrote:Typically it`s not necessary to install the infagistics setup. For calling 'Invoke Remotely' you have to add the related assemblies to your testing application. (i.e. Infragistics2.Shared, Infragistics2.WinUltraGrid, Infagistics2.Win).

Regards,
Christian
Ranorex Support Team
Hi Christian,

Thanks for the information.
The code gets compiled successfully but when it is executed I am getting the following exception:
"Ranorex.CapabilityNotSupportedException: The element does not support the required capability 'control'. at Ranorex.Adapter.AssertRequiredCapabilities() at Ranorex.Adapter..ctor(Element element) at Ranorex.Control.op_Implicit(String path).."

This is the path of the control which I am passing in my code:

Ranorex.Control cell1 = "/form[@controlname='frmNap']/container/*/container[@controlname='UicD_Fill_Panel']/container/*/container/container[@caption='' and @processname='ABC' and @controltypename='SplitterPanel' and @class='WindowsForms10.Window.8.app.0.3ce0bb8' and @instance='0']/*/*/row[@accessiblename='Folders row 1']/cell[@accessiblename='XYZ']";

Can you point out what step I am missing out please?

Regards,
Deven B.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Finding the colour of a cell in an Infragistics Grid.

Post by Support Team » Mon Oct 05, 2009 2:44 pm

You can only cast control typed elements to Ranorex.Control. Your RxPath seems to be related to a grid cell. Use Ranorex Spy and try to get the overlying UltraGrid Control element (in the detail tab in spy named as control-type: Infragistics.Win.UltraWinGrid.UltraGrid).

Regards,
Christian
Ranorex Support Team
.
Image

devenb
Posts: 24
Joined: Mon Mar 09, 2009 11:50 am
Location: Bracknell, UK

Re: Finding the colour of a cell in an Infragistics Grid.

Post by devenb » Mon Oct 05, 2009 4:28 pm

Support Team wrote:You can only cast control typed elements to Ranorex.Control. Your RxPath seems to be related to a grid cell. Use Ranorex Spy and try to get the overlying UltraGrid Control element (in the detail tab in spy named as control-type: Infragistics.Win.UltraWinGrid.UltraGrid).

Regards,
Christian
Ranorex Support Team
Hi Christian,

Thanks for pointing that out. Finally I found out it was a BasketGrid control-type and I had to add the reference of our application's assembly to the ranorex project.
So now I am getting the name of the color of the cell successfully in hexadecimal format which resolves my initial issue.

But when I try to execute the code again I am getting this error:
"Unable to copy file "obj\Debug\XYZ.exe" to "bin\Debug\XYZ.exe". The process cannot access the file 'bin\Debug\XYZ.exe' because it is being used by another process. (MSB3021)",
where XYZ.exe is the Ranorex project exe.
The only way I can overcome this error is by restarting the Application under test.

Do I have to release the control object of the application used in the code?

Regards,
Deven B.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Finding the colour of a cell in an Infragistics Grid.

Post by Support Team » Mon Oct 05, 2009 4:39 pm

The DLL that contains the delegate method called by Control.InvokeRemotely needs to be loaded by the automated application and therefore stays locked until the application is closed. You can, however, move the delegate method to a separate DLL, that way only this DLL will be locked and you can keep on changing and compiling the rest of your code. See following forum thread for more information: http://www.ranorex.com/forum/post2516.html

Regards,
Alex
Ranorex Support Team
.
Image

devenb
Posts: 24
Joined: Mon Mar 09, 2009 11:50 am
Location: Bracknell, UK

Re: Finding the colour of a cell in an Infragistics Grid.

Post by devenb » Mon Oct 05, 2009 4:44 pm

Support Team wrote:The DLL that contains the delegate method called by Control.InvokeRemotely needs to be loaded by the automated application and therefore stays locked until the application is closed. You can, however, move the delegate method to a separate DLL, that way only this DLL will be locked and you can keep on changing and compiling the rest of your code. See following forum thread for more information: http://www.ranorex.com/forum/post2516.html

Regards,
Alex
Ranorex Support Team
Thanks Alex for the quick reply.
I will try to get the delegate method out of the current project.

Regards,
Deven B.

devenb
Posts: 24
Joined: Mon Mar 09, 2009 11:50 am
Location: Bracknell, UK

Re: Finding the colour of a cell in an Infragistics Grid.

Post by devenb » Tue Oct 06, 2009 1:03 pm

Hi Alex,

I built a DLL for the delegate method and added a reference for the DLL to the project.
But when I compile the code it does not compiles and gives error messages as "The name 'GetBackgroundColor' does not exist in the current context(CS0103)."

What wrong I am doing here?

Regards,
Deven B.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Finding the colour of a cell in an Infragistics Grid.

Post by Support Team » Tue Oct 06, 2009 3:55 pm

Did you forget to move the reference to the Infragistics Grid DLL to the new project?
Did you add a reference to the new project to the main project?
Did you use the right namespace/class/method name for the GetBackgroundColor method (I assume it's a method)?

Regards,
Alex
Ranorex Support Team
.
Image

devenb
Posts: 24
Joined: Mon Mar 09, 2009 11:50 am
Location: Bracknell, UK

Re: Finding the colour of a cell in an Infragistics Grid.

Post by devenb » Tue Oct 06, 2009 4:41 pm

Thanks Alex,

Yes I was not passing the correct namespace/class details.
Error rectified and it works properly now.
Thanks for all the support.

Regards,
Deven B.

devenb
Posts: 24
Joined: Mon Mar 09, 2009 11:50 am
Location: Bracknell, UK

Re: Finding the colour of a cell in an Infragistics Grid.

Post by devenb » Wed Oct 07, 2009 5:18 pm

Hi Alex,

I am getting this new error now after compiling my Ranorex project.

Unable to delete file "C:\LicensedRanorex\XYZ\XYZ\bin\Debug\MyFirstDLL.dll". Access to the path 'C:\LicensedRanorex\XYZ\XYZ\bin\Debug\MyFirstDLL.dll' is denied. (MSB3061)

The only thing I have done is that I have added some more delegate methods to the DLL project.
Any reasons why it is happening?

Regards,
Deven B.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Finding the colour of a cell in an Infragistics Grid.

Post by Support Team » Thu Oct 08, 2009 8:31 am

Hi devenb,
it`s the same reason as Alex explained above. The dll gets locked if you`re modifying your delegate methods.

Regards,
Christian
Ranorex Support Team
.
Image

devenb
Posts: 24
Joined: Mon Mar 09, 2009 11:50 am
Location: Bracknell, UK

Re: Finding the colour of a cell in an Infragistics Grid.

Post by devenb » Thu Oct 08, 2009 8:52 am

Hi Christian,

Yes the dll is getting locked, but I have moved the delegate methods in to separate project, build a dll for it and then added the reference of that dll in the main Ranorex project.
What different thing can I do here? I searched the web for the error message but didnt found a solution.
Can I provide the stack of procmon so as to find out where exactly the problem lies?

Regards,
Deven B.