Ranorex Spy & Window Text

Ask general questions here.
SanMan
Posts: 153
Joined: Tue Apr 13, 2010 9:59 am

Ranorex Spy & Window Text

Post by SanMan » Fri Feb 04, 2011 1:18 pm

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...)

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

Re: Ranorex Spy & Window Text

Post by Support Team » Fri Feb 04, 2011 9:25 pm

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
.
Image

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

Re: Ranorex Spy & Window Text

Post by Support Team » Sat Feb 05, 2011 11:52 am

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
.
Image

SanMan
Posts: 153
Joined: Tue Apr 13, 2010 9:59 am

Re: Ranorex Spy & Window Text

Post by SanMan » Mon Feb 07, 2011 7:34 am

...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?

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

Re: Ranorex Spy & Window Text

Post by Support Team » Mon Feb 07, 2011 10:30 am

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
.
Image

SanMan
Posts: 153
Joined: Tue Apr 13, 2010 9:59 am

Re: Ranorex Spy & Window Text

Post by SanMan » Mon Feb 07, 2011 12:25 pm

Thank you!
That one work perfectly! :D