Ranorex 2.0 and finding Windows

Ask general questions here.
Captain Nemo
Posts: 17
Joined: Tue Dec 02, 2008 10:09 am

Ranorex 2.0 and finding Windows

Post by Captain Nemo » Tue Dec 02, 2008 3:29 pm

Anyone know how to find windows in the 2.0 preview?

Previous Versions had the Application Class.

Captain Nemo
Posts: 17
Joined: Tue Dec 02, 2008 10:09 am

Post by Captain Nemo » Tue Dec 02, 2008 4:08 pm

Answered my own question, D'oh!:

RxPath path = new RxPath("/form[@title='Form name Goes Here']");
if (RepositoryName.MainForm.FindSingle(path) != null)
Console.WriteLine("Found it!");

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 Dec 02, 2008 4:46 pm

Glad, you found that out by yourself.

The final Ranorex 2.0 release will provide a more convenient method by the use of the Host adapter.

Regards,
Alex
Ranorex Support Team

taralex
Posts: 57
Joined: Tue Nov 04, 2008 3:50 pm
Location: Michigan
Contact:

Post by taralex » Tue Dec 16, 2008 5:22 pm

trying to do the same thing here since CreateAdapterForPath method is no longer available..
what is RepositoryName.MainForm?

the following code doesn't find anything, what am I doing wrong?

Code: Select all

 
Host host = Host.Local;
RxPath path = new RxPath("/form[@title='Ranorex Documentation']");
Element elm = host.Element.FindSingle(path, 1000);            
if (elm != null)
   MessageBox.Show(elm.Role.ToString());
        

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 Dec 16, 2008 6:24 pm

The CreateAdapterForPath method is an internal method that should be used by generated repositories only. That's why we made it protected. There are much simpler ways to search for elements/adapters:

Code: Select all

Form form = "/form[@title='Ranorex Documentation']";
// or use the Host adapter
form = Host.Local["Ranorex Documentation"];
// or if you want to specify a timeout for a path
form = Host.Local.FindSingle<Form>("/form[@title='Ranorex Documentation']", 1000);
All methods searching for a single element/adapter throw an exception if no element is found. So, there is no need to check for null anymore.
taralex wrote:what is RepositoryName.MainForm?
That's code from a generated repository. RepositoryName.MainForm is not part of the Ranorex core interface.

The code you posted should work, though, did you load the default plugins by calling PluginManager.LoadDefaultPlugins()?

Regards,
Alex
Ranorex Support Team

taralex
Posts: 57
Joined: Tue Nov 04, 2008 3:50 pm
Location: Michigan
Contact:

Post by taralex » Tue Dec 16, 2008 7:14 pm

Oh, thanx a lot!
I totally forgot about this Pluginmanager thing.

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 Dec 17, 2008 9:42 am

Calling the PluginManager.LoadDefaultPlugins method won't be needed in the final release. The default plugins will be loaded automatically, you can, however, still call that method to force the plugins to be loaded at a specific time.

Regards,
Alex
Ranorex Support Team