Page 1 of 1

Ranorex Spy & Window Text

Posted: Fri Feb 04, 2011 1:18 pm
by SanMan
With Ranorex Spy, I tracked a toolbar from Windows Explorer

/form[@title='Testvideo']/element[@class='WorkerW']/form/element[@controlid='41477']/progressbar/element/toolbar[@controlid='1001']

When I delete the controlid='1001'] and press <CNTR> + <SPACE>, list of keywords opens.

List have only "class" , "controlid" and "instance".

I need to get the attribute "Window Text"; how can I get the it? (need to know the address written in toolbar...)

Re: Ranorex Spy & Window Text

Posted: Fri Feb 04, 2011 9:25 pm
by Support Team
I tried it.
It's about the control that displays the path in Windows Explorer.

When the Path Control is in edit mode I can get the text via
/form[@title='Snapshots']/element[@class='WorkerW']/container/element[@controlid='41477']/progressbar/combobox/text[@controlid='41477']
Else via
/form[@title='Snapshots']/element[@class='WorkerW']/container/element[@controlid='41477']/progressbar/element/toolbar[@controlid='1001']
But this time the parts of the path are child button elements.
/form[@title='Snapshots']/element[@class='WorkerW']/container/element[@controlid='41477']/progressbar/element/toolbar[@controlid='1001']/button[1]
has a text attribute which is the root element of the path. And so on.

One would need to get the text attribute of all buttons and concatenate them in code.

Regards,
Roland
Ranorex Support Team

Re: Ranorex Spy & Window Text

Posted: Sat Feb 05, 2011 11:52 am
by Support Team
Just as an addon to Roland's post:
SanMan wrote:I need to get the attribute "Window Text"; how can I get the it? (need to know the address written in toolbar...)
Just type in "@windowtext" or use the NativeWindow.WindowText attribute in code to access that property. Spy just does not show that attribute when hitting Ctrl+Space, since it is a volatile attribute (changing frequently) and should thus not be used in RanoreXPaths to identify elements.

Regards,
Alex
Ranorex Team

Re: Ranorex Spy & Window Text

Posted: Mon Feb 07, 2011 7:34 am
by SanMan
...or use the NativeWindow.WindowText attribute in code to access that property

This one would be great.

:oops: excuse me my ignorance :oops:
How to get that property?

string path = repo.FormOpen_file.ToolBar1001 ??? .NativeWindow.WindowText; ???

----
I did it this way (got help from forum);
object value = repo.FormOpen_file.ToolBar1001;
value = repo.FormOpen_file.ToolBar1001.Element.GetAttributeValue("windowtext");
string exp_path = Ranorex.Core.ValueConverter.ToFriendlyString(value);

Is this correct way?

Re: Ranorex Spy & Window Text

Posted: Mon Feb 07, 2011 10:30 am
by Support Team
SanMan wrote:How to get that property?
Please, read the following section in the Ranorex User Guide covering that topic:
http://www.ranorex.com/support/user-gui ... apter.html

In your case, I recommend the following code:
Ranorex.NativeWindow nw = new Ranorex.NativeWindow(repo.FormOpen_file.ToolBar1001);
string windowText = nw.WindowText;
Regards,
Alex
Ranorex Team

Re: Ranorex Spy & Window Text

Posted: Mon Feb 07, 2011 12:25 pm
by SanMan
Thank you!
That one work perfectly! :D