Page 1 of 1

Element attributes differences

Posted: Tue Sep 05, 2006 1:40 pm
by ranettix
Compared to the .NET C# sourcecode, I found a discrepancy:

C# Source
------------
A status field is defined in C# as System.Windows.Forms.StatusBarPanel.
<status-instance>.Name is a string constant.
The current field value in C# is assigned to <status-instance>.Text.

Ranorex
----------
The current field value is displayed under "Name", with Ranorex Spy.
The is no "Text" attribute, since elements don't have it.
"Role" is set to StaticText.
The current "Name" value as displayed with Ranorex Spy is not accessible
under RanorexNet - it contains the initial value only.
In other words, the current status value cannot be retrieved.

:roll:

Posted: Tue Sep 05, 2006 7:40 pm
by webops
You are right, but I think we cannot do anything at the moment, it seems to be an MSAA problem.
Ranorex uses the newest version of MSAA (Microsoft Active Accessibility Version 2.0).
Here's the Microsoft documentation for StatusBar:

Status Bar Control
...
get_accName
The status bar object itself does not have a Name property. The Name property of each pane in the status bar is the same as the displayed text.
...

See also: http://msdn.microsoft.com/library/defau ... x_823w.asp

Ranorex uses get_accName to retrieve the Name of a status bar element.
Please let me know, if you know another possibility to get the Name of a status bar element.

Jenö Herget
Ranorex Team

Posted: Wed Sep 06, 2006 9:01 am
by ranettix
With RanorexNet I can retrieve only the initial value of the statusbar pane
element, in "<element-instance>.Name" (the value returned never changes).

With Ranorex Spy I see the actual contents of the statusbar pane
element, same as displayed in the GUI.

Are there different interfaces used in RanorexNet and Ranorex Spy ?

Posted: Wed Sep 06, 2006 9:33 pm
by webops
> Are there different interfaces used in RanorexNet and RanorexSpy ?

No, they both use the same MSAA 2.0 COM objects from C++.

The elements of a control are identified by Role, Name and ClassName in Ranorex.
See also: http://msdn.microsoft.com/library/defau ... wforms.asp
This can make using the element name impossible, if it is dynamically changed.

But you can retrieve the text of a status bar pane as follows:

Code: Select all

// Find the control
StatusStrip statusStrip = form.FindStatusStrip("statusStrip1");
...
// Find the status bar element (child) in the control
Element statusBar = statusStrip.Element.FindChild(Role.StatusBar);
if (statusBar != null)
{
    // Get the first pane element
    Element statusBarElement1 = statusBar.GetChild(0);
    if (statusBarElement1 != null)
        Console.WriteLine("Pane1Text={0}", statusBarElement1.Name);
}
Study the output of the DumpElementTree(statusStrip.Element) function in RanorexVS20054Sample3, if you don't understand the code.

Jenö Herget
Ranorex Team

Posted: Thu Sep 07, 2006 9:49 am
by ranettix
Good tip.
The astonishing experience is that the statusBarElement1 pointer
cannot be used throughout the rest of the program.

It has to be derived from StatusStrip every time it's used again (?).

Posted: Thu Sep 07, 2006 9:54 pm
by webops
Yes, you are right, we have a problem with dynamically changed element name of a status bar pane in the version 0.9.2.
You must get the child element every time you need the name.
We will fix this problem in a future version.

Please use the workaround above until that time.

Jenö Herget
Ranorex Team

Posted: Sat Sep 16, 2006 6:14 pm
by webops
The problem with dynamically changed element name of a status bar pane has been fixed
(the bug posted at 07 Sep 2006 08:49 am by ranettix).

Use 0.9.4 Beta1 or higher if you have this problem.

Jenö Herget
Ranorex Team