Dialog and ModalDialog : Automation API

Dialog and ModalDialog

Class library usage, coding and language questions.

Dialog and ModalDialog

Postby lasombra » Fri Mar 07, 2008 9:30 pm

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: Select all
+window "main window"
+-window "Standard User" (ModalDialog)
  +-dialog "Standard User"
    +button "Yes"
    +button "No"

Here I try to show the situation:
Code: Select all
+--------------------------------------+
|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: Select all
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?
lasombra
 
Posts: 9
Joined: Tue Mar 04, 2008 2:36 pm

Postby lasombra » Fri Mar 07, 2008 9:52 pm

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: Select all
Ranorex.Application.FindFormClassName("#32770");
lasombra
 
Posts: 9
Joined: Tue Mar 04, 2008 2:36 pm

Postby Support Team » Mon Mar 10, 2008 10:14 am

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 :D

Alex
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4840
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby lasombra » Mon Mar 10, 2008 2:28 pm

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: Select all
foreach (Ranorex.Form topform in Ranorex.Application.Forms)
{
   if (topform.ClassName.Equals("#32770"))
   {
      Console.WriteLine("Form= " + topform.Text + ", Classname=" + topform.ClassName);
   }
}

gives me
Code: Select all
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: Select all
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: Select all
for (int k = 0; k < localForm.Element.ChildCount; k++)
{
   Console.WriteLine("Text= " + localForm.Element.GetChild(k).Name);
}

gives me
Code: Select all
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?
lasombra
 
Posts: 9
Joined: Tue Mar 04, 2008 2:36 pm

Postby Support Team » Mon Mar 10, 2008 4:10 pm

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: Select all
Form dialog = Ranorex.Application.FindForm("Standard User", Ranorex.SearchMatchMode.MatchExact, "#32770");


Regards,
Alex
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4840
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby lasombra » Mon Mar 10, 2008 4:57 pm

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().
lasombra
 
Posts: 9
Joined: Tue Mar 04, 2008 2:36 pm

Postby Support Team » Mon Mar 10, 2008 5:50 pm

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
User avatar
Support Team
Site Admin
 
Posts: 4840
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests