Page 1 of 1

Ranorex 2.0 and finding Windows

Posted: Tue Dec 02, 2008 3:29 pm
by Captain Nemo
Anyone know how to find windows in the 2.0 preview?

Previous Versions had the Application Class.

Posted: Tue Dec 02, 2008 4:08 pm
by Captain Nemo
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!");

Posted: Tue Dec 02, 2008 4:46 pm
by Support Team
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

Posted: Tue Dec 16, 2008 5:22 pm
by taralex
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());
        

Posted: Tue Dec 16, 2008 6:24 pm
by Support Team
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

Posted: Tue Dec 16, 2008 7:14 pm
by taralex
Oh, thanx a lot!
I totally forgot about this Pluginmanager thing.

Posted: Wed Dec 17, 2008 9:42 am
by Support Team
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