Ranorex 1.2
.Net 2.0
I've just upgraded to Ranorex 1.2
When I go to recompile I get an error for every instance of
"Control <control> = <Form>.GetFocus()"
Investigation shows that this method is missing from the latest release.
Cheers
Gryphyn
Missing GetFocus() method
I tried the following code with the VS2005Application.exe and it worked for me:Investigation shows that this method is missing from the latest release.
Code: Select all
for (int i = 0; i < 60; i++)
{
Control control = Form.GetFocus();
Console.WriteLine("Control = {0}", control.GetType());
Application.Sleep(1000);
}
Jenö
Ranorex Team
Missing GetFocus() method
Hello,
I have a AUT main GUI and sometimes some MessageBoxes (from the AUT) which must be handled before the next step can be done on the AUT main GUI. So when I recognize the AUT has not the focus I want to get the Form (MessageBox) with the focus and click "OK" (for example).
Now my question: How can I get this form?
(Using Ranorex 2.2.3 - I can't find a GetFocus() method.)
I have a AUT main GUI and sometimes some MessageBoxes (from the AUT) which must be handled before the next step can be done on the AUT main GUI. So when I recognize the AUT has not the focus I want to get the Form (MessageBox) with the focus and click "OK" (for example).
Now my question: How can I get this form?
(Using Ranorex 2.2.3 - I can't find a GetFocus() method.)
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Missing GetFocus() method
Hi!
I think what you are looking for is the following blog
http://www.ranorex.com/blog/handling-di ... up-windows
on our homepage. This blog handle unexpected Dialog and Pop Up windows and click for example the button "OK" when a window appears.
Regards,
Peter
Ranorex Support Team
I think what you are looking for is the following blog
http://www.ranorex.com/blog/handling-di ... up-windows
on our homepage. This blog handle unexpected Dialog and Pop Up windows and click for example the button "OK" when a window appears.
In Ranorex 2.X every element/adapter has the HasFocus property instead.spot wrote:(Using Ranorex 2.2.3 - I can't find a GetFocus() method.)
Regards,
Peter
Ranorex Support Team
Re: Missing GetFocus() method
Thank you very much for the very interesting link.
Unfortunately I search for a solution which is a little bit different. I would like to know which Form (e. g. MessageBox) is the one with the focus and then I would like to get the name or title of this Box.
Then I can decide if it is the expected Form (MsgBox) at the right time, can do something (depending to the meaning of the Box), can close the Box an can do the next test step on the AUT.
The solution in the given link closes Boxes in a separate thread when ever they open, and the main test program does not know which one it was and can't do something with this additional information (the meaning of the box), because only the separate thread knows about its existence.
And when a real unexpected box appears (which title isn't known before) there are no way to get this Form/Box and click OK, or Alt+F4 just as a try to go on with the test (of course with WARN and Screenshot - but maybe with the chance that the test can be finished).
So, the question again please: Do you know any method to get the MessageBox/form/control/name of or something else of the object with the focus?
Unfortunately I search for a solution which is a little bit different. I would like to know which Form (e. g. MessageBox) is the one with the focus and then I would like to get the name or title of this Box.
Then I can decide if it is the expected Form (MsgBox) at the right time, can do something (depending to the meaning of the Box), can close the Box an can do the next test step on the AUT.
The solution in the given link closes Boxes in a separate thread when ever they open, and the main test program does not know which one it was and can't do something with this additional information (the meaning of the box), because only the separate thread knows about its existence.
And when a real unexpected box appears (which title isn't known before) there are no way to get this Form/Box and click OK, or Alt+F4 just as a try to go on with the test (of course with WARN and Screenshot - but maybe with the chance that the test can be finished).
So, the question again please: Do you know any method to get the MessageBox/form/control/name of or something else of the object with the focus?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Missing GetFocus() method
Hi!
Peter
Ranorex Support Team
You can try following code:spot wrote:So, the question again please: Do you know any method to get the MessageBox/form/control/name of or something else of the object with the focus?
//Search for the active foreground window and checks if "active" state is true Ranorex.Form myActiveForm = Host.Local.FindSingle("/form[@active='True']");Regards,
Peter
Ranorex Support Team
Re: Missing GetFocus() method
Thank you!
This could be the thing I've searched for - I will try it (a first short test worked).
I don't know, but maybe this could be a additional information to the link http://www.ranorex.com/blog/handling-di ... up-windows you told me?
Regards
This could be the thing I've searched for - I will try it (a first short test worked).
I don't know, but maybe this could be a additional information to the link http://www.ranorex.com/blog/handling-di ... up-windows you told me?
Regards