Verify object properties when object is a graphic ChatFx

Ask general questions here.
CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Verify object properties when object is a graphic ChatFx

Post by CarlaNeves » Thu Feb 26, 2009 2:21 pm

I'm having a problem to access the properties of an object. The object is a ChartFx. I can only access the information of the control and I need to verify the colors of the background of the graphic.
Can someone help?

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

Post by Support Team » Fri Feb 27, 2009 2:19 pm

Hello CarlaNeves,
Ranorex 2.0 gets the Chartfx 3rd Party Control elements as a Ranorex.Unknown object.

Create a Ranorex.Control object instead and use the GetProperty() function.

example from the ChartFx Borders and Background Sample Application of the ChartFx 7.0 trial version:

Code: Select all

Ranorex.Control elementBordersandBackgrounds = "/form[@controlname='Form1' and @title='Borders and Backgrounds']/element/element[@processname='BordersandBackgrounds' and @controltypename='a']";
System.Drawing.Color color1 = (System.Drawing.Color)elementBordersandBackgrounds.GetPropertyValue("BackColor");
or PlotAreaColor

Code: Select all

Ranorex.Unknown elementChart1 = "/form[@controlname='Form1' and @title='Borders and Backgrounds']/element";
System.Drawing.Color color = (System.Drawing.Color)elementChart1.GetPropertyValue("PlotAreaColor");
Regards,
Christian
Ranorex Support Team

CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Post by CarlaNeves » Mon Apr 06, 2009 2:29 pm

Hello,

For those examples and for a few other properties such as width, height or font, the Ranorex is able to get their values, but for many others, for example Gallery I get the following error:

Ranorex.ActionFailedException: Action 'getpropertyvalue' failed on element '{Unknown:bq}'. ---> System.MissingFieldException: Property 'Gallery' not found. at Ranorex.Plugin.WinFormsFlavorElement.GetPropertyValue(String name) at Ranorex.Plugin.WinFormsFlavorElement.InvokeAction(Element element, String name, Object[] args) at Ranorex.Core.Element.InvokeAction(String name, Object[] args) --- End of inner exception stack trace --- at Ranorex.Core.Element.InvokeAction(String name, Object[] args) at Ranorex.Control.GetPropertyValue(String name) at Trend.SC02.Start() in c:\RanorexStudio Projects\Trend\Trend\SC02.cs:line 101 at IFX_Trend.Program.Main(String[] args) in c:\RanorexStudio Projects\Trend\Trend\Program.cs:line 67

Can you please help me with this?

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

Post by Support Team » Tue Apr 07, 2009 1:03 pm

Hello,
it looks like that the property gallerie and maybe other properties of the chartFX7 controls are set to the attribute "[Browsable(false)]".

Use the "Control.InvokeMethod"(via reflection) method instead of "GetPropertyValue" like:

Code: Select all

Ranorex.Control elementChart1 = "/form[@controlname='Form1']/element";
object obj = elementChart1.InvokeMethod("get_Gallery");
Gallery gallerie = (Gallery)obj;
Regards,
Christian
Ranorex Support Team

CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Post by CarlaNeves » Tue Apr 07, 2009 1:51 pm

Hi,

I tried to do as you said:

Code: Select all

Ranorex.Control elementChart1 = "/form[@controlname='FRM_Main']/container/element/*/*/container[@caption='' and @processname='MyApplication' and @controltypename='WindowDockingArea' and @class='WindowsForms10.Window.8.app.0.bf7771' and @instance='1']/container[@caption='' and @processname='MyApplication' and @controltypename='DockableWindow' and @class='WindowsForms10.Window.8.app.0.bf7771' and @instance='0']/*/container[@controlname='splitContainerResults']/container[@controlname='panel1']/*/*/element[@controlname='bq']";
object obj = elementChart1.InvokeMethod("get_Gallery");
Gallery gallerie = (Gallery)obj;
And I got the following compilation errors:

No overload for method 'InvokeMethod' takes '1' arguments (CS1501) - C:\RanorexStudio Projects\Trend\Trend\SC02.cs:101,17.

The type or namespace name 'Gallery' could not be found (are you missing a using directive or an assembly reference?) (CS0246) - C:\RanorexStudio Projects\Trend\Trend\SC02.cs:102,24.

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

Post by Support Team » Tue Apr 07, 2009 3:35 pm

Sorry,
i forgot to say that you have to use Ranorex 2.0.2(newest version) to call the InvokeMethod in this case. For casting to "Gallery" add the chartfx7 references (ChartFX.WinForms.dll) to your testing project.

Regards,
Christian
Ranorex Support Team

CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Post by CarlaNeves » Tue Apr 07, 2009 6:02 pm

Hi, again...

After several attempts, one follows, I haven't had any luck with the results, I always get a similar error.

Code: Select all

Ranorex.Control elementChart1 = "/form[@controlname='FRM_Main']/container/element/*/*/container[@caption='' and @processname='MyApplication' and @controltypename='WindowDockingArea' and @class='WindowsForms10.Window.8.app.0.bf7771' and @instance='1']/container[@caption='' and @processname='MyApplication' and @controltypename='DockableWindow' and @class='WindowsForms10.Window.8.app.0.bf7771' and @instance='0']/*/container[@controlname='splitContainerResults']/container[@controlname='panel1']/*/*/element[@controlname='bq']";
object obj = elementChart1.InvokeMethod("get_Gallery");
ChartFX.WinForms.Gallery gallerie = (ChartFX.WinForms.Gallery)obj;
The error:

Ranorex.ActionFailedException: Action 'invokemethod' failed on element '{Unknown:bq}'. ---> System.MissingMethodException: Method 'ChartFX.WinForms.al.get_Gallery' not found.] at Ranorex.Plugin.WinFormsFlavorElement.InvokeMethod(BindingFlags flags, String name, Object[] args) at Ranorex.Plugin.WinFormsFlavorElement.InvokeAction(Element element, String name, Object[] args) at Ranorex.Core.Element.InvokeAction(String name, Object[] args) --- End of inner exception stack trace --- at Ranorex.Core.Element.InvokeAction(String name, Object[] args) at Ranorex.Control.InvokeMethod(BindingFlags flags, String name, Object[] args) at Ranorex.Control.InvokeMethod(String name) at Trend.SC02.Start() in c:\RanorexStudio Projects\Trend\Trend\SC02.cs:line 106 at Trend.Program.Main(String[] args) in c:\RanorexStudio Projects\Trend\Trend\Program.cs:line 67

Please advise,
Thanks in advance,
Carla Neves

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

Post by Support Team » Wed Apr 08, 2009 8:24 am

It looks like you are using the wrong element. The element you use to call InvokeMethod corresponds to a control of type ChartFX.WinForms.al that obviously does not have a property called "Gallery". As far as I know only the ChartFX.WinForms.Chart class has a "Gallery" property, so you need an element which ControlType attribute is "ChartFX.WinForms.Chart".

Please, try to spy that chart again and search for an element that has a ControlType attribute value of "ChartFX.WinForms.Chart". Then use the path of that element in your code. I assume that the element you currently use is a child of the actual element corresponding to the Chart control.

Regards,
Alex
Ranorex Support Team

CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Post by CarlaNeves » Wed Apr 08, 2009 1:10 pm

Hi,

You were absolutely right about that, the element I had was just the chart when I should had instead the element above.

It works great!!

Thank you very much for your time and explanations!!

Carla Neves

CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Post by CarlaNeves » Thu Apr 09, 2009 10:38 am

Hi,

I'm having a problem, when I run the next piece of code:

Code: Select all

Ranorex.Control elementChart1 = "/form[@controlname='FRM_Main']/container/element/*/*/container[@caption='' and @processname='MyApplication' and @controltypename='WindowDockingArea' and @class='WindowsForms10.Window.8.app.0.bf7771' and @instance='1']/container[@caption='' and @processname='MyApplication' and @controltypename='DockableWindow' and @class='WindowsForms10.Window.8.app.0.bf7771' and @instance='0']/*/container[@controlname='splitContainerResults']/container[@controlname='panel1']/*/element";
object obj = elementChart1.InvokeMethod("get_Panes");
The InvokeMethod doesn't fail but the value of obj is always null, the same happens for the properties AxisX, AxisY, AxesX, AxesY, Titles, etc...

Can someone please help me?

Thank you,
Carla Neves

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

Post by Support Team » Thu Apr 09, 2009 10:52 am

I bet that the types of these properties are not Serializable, i.e. they can't be transferred from one process to the other. There exist workarounds, though, e.g. you can use the InvokeRemotely method to get the relevant data as serializable types.

Please read the following blog that covers the topic on how to transfer unserializable data to and from .NET controls:
http://www.ranorex.com/blog/transfering ... et-control

Another example of the InvokeRemotely method can be found in the following forum post:
http://www.ranorex.com/forum/ranorex-20 ... -t563.html

Regards,
Alex
Ranorex Support Team

CarlaNeves
Posts: 14
Joined: Thu Feb 26, 2009 2:08 pm

Post by CarlaNeves » Mon Apr 20, 2009 10:07 am

Hi,

With the InvokeRemotely method I am able to get the values of the properties I need.

Thank you!!

Carla Neves