Ranorex

Error in Form.GetFocus()

 
Post new topic   Reply to topic    Ranorex Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
arishahsan



Joined: 18 Jan 2007
Posts: 26

PostPosted: Mon Apr 16, 2007 7:58 am    Post subject: Error in Form.GetFocus()
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.
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Mon Apr 16, 2007 9:25 pm    Post subject:
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:
Code: click into code to enlarge
Form form = Application.FindFormTitle("MyFormText");
Control MsgMngrFocusedButton = Form.GetFocus();
Console.WriteLine(MsgMngrFocusedButton.Text);
Mouse.ClickControl(MsgMngrFocusedButton);

Gabor
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
arishahsan



Joined: 18 Jan 2007
Posts: 26

PostPosted: Tue Apr 17, 2007 6:49 am    Post subject: 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.
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Wed Apr 18, 2007 10:45 pm    Post subject:
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.

Code: click into code to enlarge
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);


Which Ranorex and OS Version do you use?

Jenö
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
arishahsan



Joined: 18 Jan 2007
Posts: 26

PostPosted: Thu Apr 19, 2007 3:03 pm    Post subject: I got this error in version 0.9.2
It is working fine in version 1.1
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> Bug Reports All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
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