| View previous topic :: View next topic |
| Author |
Message |
lasombra
Joined: 04 Mar 2008 Posts: 9
|
Posted: Fri Mar 07, 2008 9:30 pm Post subject: Dialog and ModalDialog |
|
I have a Ranorex test client, which opens on the application-to-test a modal dialog "Standard User" where I enter some user information like username and password. If all information are entered, I click on "OK". Well if the user exists, a dialog "Standard User" appears, where I either must to click "Yes" or "No". Here the tree which I receive of UISpy:
Code: click into code to enlarge
+window "main window"
+-window "Standard User" (ModalDialog)
+-dialog "Standard User"
+button "Yes"
+button "No"
Here I try to show the situation:
Code: click into code to enlarge
+--------------------------------------+
|Standard User |
+--------------------------------------+
| |
| User Name [ ] |
| +===========================+ |
| Passw |Standard User |<---- this dialog I cannot detect
| +===========================+ |
| Confi | [YES] [NO] | |
| +===========================+ |
| |
+--------------------------------------+
My Problem is, that I couldn't get in any form the "dialog" which seems to be a child of the window "Standard User".
Code: click into code to enlarge
localControl = myModalDialog.FindClassName("#32770"); //myModalDialog = Ranorex.Form
localControl = myModalDialog.FindChildText("Standard User");
localElement = myForm2.Element.FindChild(Ranorex.Role.Dialog, "Standard User");
Exists a possibility to get the dialog and press one of the buttons? |
|
| Back to top |
|
 |
lasombra
Joined: 04 Mar 2008 Posts: 9
|
Posted: Fri Mar 07, 2008 9:52 pm Post subject: |
|
In the end I got it: First RTFM A Dialog is a Ranorex.Form thus I can search by classname on the Ranorex.Application:
Code: click into code to enlarge
Ranorex.Application.FindFormClassName("#32770");
|
|
| Back to top |
|
 |
Support Team Site Admin
Joined: 07 Jul 2006 Posts: 344
|
Posted: Mon Mar 10, 2008 10:14 am Post subject: |
|
Dialogs are top-level windows, i.e. the do not have a parent window. So you got to search them using the Ranorex.Application class.
Glad you could do it on your own
Alex
Ranorex Support Team |
|
| Back to top |
|
 |
lasombra
Joined: 04 Mar 2008 Posts: 9
|
Posted: Mon Mar 10, 2008 2:28 pm Post subject: |
|
If dialogs are top level windows, why UISpy shows me the dialog as a child? Well this is another thing... But still I have a problem with the dialog. I get the dialog by classname, and is the only dialog.
Code: click into code to enlarge
foreach (Ranorex.Form topform in Ranorex.Application.Forms)
{
if (topform.ClassName.Equals("#32770"))
{
Console.WriteLine("Form= " + topform.Text + ", Classname=" + topform.ClassName);
}
}
gives me
Code: click into code to enlarge
Form= Standard User, Classname=#32770
So far, so good, but the form that I found, don't contains any controls, thus the following code don't show me anything:
Code: click into code to enlarge
foreach (Ranorex.Control myControl in localForm.Controls)
{
Console.WriteLine("Text= " + myControl.Text + ", " + myControl.ClassName);
}
On the other side, I get childrens, but the children notes are not of the expected dialog.
Code: click into code to enlarge
for (int k = 0; k < localForm.Element.ChildCount; k++)
{
Console.WriteLine("Text= " + localForm.Element.GetChild(k).Name);
}
gives me
Code: click into code to enlarge
Text= System
Text=
Text= Application
Text= Google Calendar Sync 0.9.3.0
Text= Vertical
Text= Vertical
Text=
"Google Calendar Sync" is an application that is running in the system tray. Before I had childs of an Outlook reminder - the reminder came in the morning, I closed it and I closed too Outlook, but Outlook still was running as a process. After kill the process, I get the results mentioned above.
This behavior is very rare. Any suggestions? |
|
| Back to top |
|
 |
Support Team Site Admin
Joined: 07 Jul 2006 Posts: 344
|
Posted: Mon Mar 10, 2008 4:10 pm Post subject: |
|
| lasombra wrote: |
| If dialogs are top level windows, why UISpy shows me the dialog as a child? |
Sorry, I was a little imprecise: dialog windows do have parent windows, but they are not the child of that window. So you got to search them as if they were top-level windows.
It seems that you are sometimes finding the wrong dialog. There are many dialogs with classname "#32770" open all the time, even if they are invisible. It's much safer to search for the window caption "Standard User" and the classname.
Code: click into code to enlarge
Form dialog = Ranorex.Application.FindForm("Standard User", Ranorex.SearchMatchMode.MatchExact, "#32770");
Regards,
Alex
Ranorex Support Team |
|
| Back to top |
|
 |
lasombra
Joined: 04 Mar 2008 Posts: 9
|
Posted: Mon Mar 10, 2008 4:57 pm Post subject: |
|
Thanks Alex, this is what I am looking for, unfortunately Ranorex doesn't provide a FindForm(), although mentioned in the documentation.
Assembly: RanorexNet (Module: RanorexNet) Version: 1.2.0.0
DevEnv: Visual C# Express 2008
The ObjectBorwser of the Visual Express only provides me only the methods FindFormTitle() and FindFormClassName(). |
|
| Back to top |
|
 |
Support Team Site Admin
Joined: 07 Jul 2006 Posts: 344
|
Posted: Mon Mar 10, 2008 5:50 pm Post subject: |
|
| lasombra wrote: |
| unfortunately Ranorex doesn't provide a FindForm(), although mentioned in the documentation. |
You need to reference the RanorexNet.dll from the bin\Net2.0-Pro directory! This method is only supported in the Pro version of Ranorex.
Alex
Ranorex Support Team |
|
| Back to top |
|
 |
|