Hi,
I was trying to write a function which would replace the need of adding delay to the code when waiting for applications to load.
Whenever any application is initialised this function would be called till the application form is visible.
Here is the sample code:
public static void Start()
{
repo.BaseMenuBar.Outlookshortcut.Click(Location.Center);
wait_For_Application_ToLoad(repo.Outlookform.Outlookform);
}
public static void wait_For_Application_ToLoad(Element application_Path)
{
try {
if (application_Path.Visible==false) {
Delay.Ms(2000);
wait_For_Application_ToLoad(application_Path);
}
}
catch (RanorexException) {
}
}
Now even when the form is visible, the validation "application_Path.Visible" is validated as false and the loop continues.
I know I am certainly missing a step somewhere or is it a wrong way of coding this?
Any help would be great.
Thanks,
Deven B.
Need help with a function
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Need help with a function
Hi,
the problem with your function seems that the window handle on start is not the same when you call the function. This means when your are coding a validation like
Regards,
Peter
Ranorex Support Team
the problem with your function seems that the window handle on start is not the same when you call the function. This means when your are coding a validation like
while(repo.FormInbox.OutlookForm.Visible == false) Delay.Milliseconds(20);, on every while-cycle Ranorex is searching for the element and get the attribute of the item. In your case Ranorex is searching once for the element and doesn't change the attribute in your function.
Regards,
Peter
Ranorex Support Team
Re: Need help with a function
Hi Peter,Support Team wrote:Hi,
the problem with your function seems that the window handle on start is not the same when you call the function. This means when your are coding a validation likewhile(repo.FormInbox.OutlookForm.Visible == false) Delay.Milliseconds(20);, on every while-cycle Ranorex is searching for the element and get the attribute of the item. In your case Ranorex is searching once for the element and doesn't change the attribute in your function.
Regards,
Peter
Ranorex Support Team
Thanks for the reply.
I executed the code in debug mode with a breakpoint at line "if (application_Path.Visible==false) {".
When I hover the mouse over the application_Path it shows me the name of the form which I am looking for. Doesnt it means that it is getting the attribute of the element correctly?
Any other way of coding this?
Cheerz,
Deven B.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Need help with a function
Hi,
the problem is that Outlook generates a Splash Screen and IMHO it is more wise to use a menubar of outlook to validate if the programm is started, because there is more guarantee that the programm is finished with loading.
Regards,
Peter
Ranorex Support Team
the problem is that Outlook generates a Splash Screen and IMHO it is more wise to use a menubar of outlook to validate if the programm is started, because there is more guarantee that the programm is finished with loading.
Regards,
Peter
Ranorex Support Team
Re: Need help with a function
Hi Peter,Support Team wrote:Hi,
the problem is that Outlook generates a Splash Screen and IMHO it is more wise to use a menubar of outlook to validate if the programm is started, because there is more guarantee that the programm is finished with loading.
Regards,
Peter
Ranorex Support Team
Outlook is just an example which I was using. Sorry for the miscommunication.
We have different AUT and in past I have used the Delay option more than 100 times to wait for an window or form to get loaded. Since I have started working on a new project I wanted to substitute that with a simple function to which I can pass any element (form or window) and the function will wait till it is loaded.
Am I calling the function correctly?
Cheerz,
Deven B.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Need help with a function
What your method actually does, is waiting till the Element you pass in gets visible. If Ranorex cannot find the element, the wait_For_Application_ToLoad method will never be called, since getting the element for the repository item (e.g. repo.Outlookform.Outlookform) will already throw an exception.
If that is what your method should do, then everything's correct
The reason why your code is not working for Outlook is not the wait_For_Application_ToLoad method, but the element you pass in to that method. Like Peter, I guess that your Outlookform.Outlookform repository item actually finds the Outlook splash screen, not the Outlook main window. Try to adapt the RxPath of that repository item such that it does not match the splash screen, e.g. (like Peter suggested) wait for a Outlook menu item to get visible.
Regards,
Alex
Ranorex Support Team
If that is what your method should do, then everything's correct
The reason why your code is not working for Outlook is not the wait_For_Application_ToLoad method, but the element you pass in to that method. Like Peter, I guess that your Outlookform.Outlookform repository item actually finds the Outlook splash screen, not the Outlook main window. Try to adapt the RxPath of that repository item such that it does not match the splash screen, e.g. (like Peter suggested) wait for a Outlook menu item to get visible.
Regards,
Alex
Ranorex Support Team
Re: Need help with a function
Hi Alex,
Thanks for the information.
Yes passing an element to the wait_For_Application_ToLoad method, which is not yet visible throws an exception .
Is there a way where I can pass any control of an invisible element without an exception been thrown by Ranorex?
Like passing a Rxpath as string etc?
Cheerz,
Deven B.
Thanks for the information.
Yes passing an element to the wait_For_Application_ToLoad method, which is not yet visible throws an exception .
Is there a way where I can pass any control of an invisible element without an exception been thrown by Ranorex?
Like passing a Rxpath as string etc?
Cheerz,
Deven B.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Need help with a function
You already answered your question: pass the RxPath. Or use the RepoItemInfo object corresponding to the repository item. I.e. for a repository item named "MyItem", pass in the "MyItemInfo". See the following forum thread for more info: http://www.ranorex.com/forum/post4535.htmldevenb wrote:Like passing a Rxpath as string etc?
Regards,
Alex
Ranorex Support Team