I have used the following code
Form CyMsgForm = Application.FindFormTitle("MyFormText")
Control MsgMngrFocusedButton = CyMsgForm.GetFocus();
Mouse.ClickControl(MsgMngrFocusedButton);
The problem is that when I tried this the mouse doesn't click on
the button in spite of it it clicks beside the control.
Error in Form.GetFocus()
Hi,
I can't reproduce this bug.
I think the GetFocus() method returns another control you want to click on.
Please check the focused control's title:
Gabor
Ranorex Team
I can't reproduce this bug.
I think the GetFocus() method returns another control you want to click on.
Please check the focused control's title:
Code: Select all
Form form = Application.FindFormTitle("MyFormText");
Control MsgMngrFocusedButton = Form.GetFocus();
Console.WriteLine(MsgMngrFocusedButton.Text);
Mouse.ClickControl(MsgMngrFocusedButton);
Ranorex Team
-
- Posts: 26
- Joined: Thu Jan 18, 2007 12:04 pm
I have tried ur idea and gives the name of same control
I have tried ur idea and it gives the name of the same control which I wanted to click.
You can reproduce it like this
Open Notepad and write something and try to close it without saving , so you will get a message box which is asking that do you want to save or not. Now run the following code.
Form MsgMng = Application.FindFormTitle("Notepad");
Control MsgYes = MsgMng.GetFocus();
Console.WriteLine(MsgYes.Text);
Mouse.MoveToControl(MsgYes);
Mouse.ClickControl(MsgYes);
The point to be noted is that the control doesn't have control name and this is applicable to any .net application, bcoz Message forms control name cannot be assigned by devlopers.
You can reproduce it like this
Open Notepad and write something and try to close it without saving , so you will get a message box which is asking that do you want to save or not. Now run the following code.
Form MsgMng = Application.FindFormTitle("Notepad");
Control MsgYes = MsgMng.GetFocus();
Console.WriteLine(MsgYes.Text);
Mouse.MoveToControl(MsgYes);
Mouse.ClickControl(MsgYes);
The point to be noted is that the control doesn't have control name and this is applicable to any .net application, bcoz Message forms control name cannot be assigned by devlopers.
We cannot reproduce this bug.
If we do the same you described, the Form with the title "Notepad" will be activated and the mouse clicks the Yes button.
But we had to change your code a little bit:
Control MsgYes = Form.GetFocus();
Can you please try the following code and post the command line output in your replay.
Which Ranorex and OS Version do you use?
Jenö
Ranorex Team
If we do the same you described, the Form with the title "Notepad" will be activated and the mouse clicks the Yes button.
But we had to change your code a little bit:
Control MsgYes = Form.GetFocus();
Can you please try the following code and post the command line output in your replay.
Code: Select all
Form MsgMng = Application.FindFormTitle("Editor");
Control MsgYes = Form.GetFocus();
Console.WriteLine("Text={0} Class={1} Type={2}",
MsgYes.Text, MsgYes.ClassName, MsgYes.GetType());
Mouse.MoveToControl(MsgYes);
Mouse.ClickControl(MsgYes);
Jenö
Ranorex Team
-
- Posts: 26
- Joined: Thu Jan 18, 2007 12:04 pm
I got this error in version 0.9.2
It is working fine in version 1.1