| View previous topic :: View next topic |
| Author |
Message |
dave0989
Joined: 12 Jul 2007 Posts: 3
|
Posted: Wed Jul 18, 2007 10:53 pm Post subject: pushButton |
|
Well I have accomplished a lot so far with automating the GUI testing at my work... I'm happy with Ranorex and I plan on writing a proposal for a license..
Anyways I have a question regarding pushbutton. So far I have tried to write the code myself with no success then I tried to use RanorexRecorder to record the process of selecting okay from a child dialog box that apprears.
// Find child element by Role=PushButton Name=OK ClassName=Button
element = formElement.FindChild(Role.PushButton, "OK", "Button");
Mouse.ClickControl(control, MouseButtonType.LeftButton, new Point(47, 12), 1, 953);
What happens is the cursur goes right past the dialog box and I get an error message.
It throws a commandfailed exception. |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Thu Jul 19, 2007 12:02 am Post subject: |
|
Did you use the dialog element in the FindChild(Role.PushButton) function?
The following code works with the sample VS2005Application.exe:
It opens the FileOpen dialog, finds the dialog, sets the file name and clicks the Open PushButton.
Code: click into code to enlarge
ret = menuStrip.SelectItemText("Submenu3", "FileOpen");
Form openFileDialog = Application.FindFormTitle("Open",SearchMatchMode.MatchExact,true,1000) ;
if (openFileDialog == null)
{
Console.WriteLine("ERROR: OpenFileDialog not found ");
return 1;
}
Element fileEditControl = openFileDialog.Element.FindChild(Role.Text,"File name:");
if( fileEditControl != null)
fileEditControl.Value = "D:\\Ranorex-1.2.0\\Bin\\RanorexSpy.exe";
Element openButton = openFileDialog.Element.FindChild(Role.PushButton,"Open","Button");
if (openButton != null )
Mouse.ClickElement(openButton);
Please try it and post a replay if it doesn't work.
Jenö
Ranorex Team |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|