Getting IE browser to be in focus

Ranorex Spy, Recorder, and Studio.
zivshapira
Posts: 14
Joined: Mon Mar 18, 2013 1:06 pm

Getting IE browser to be in focus

Post by zivshapira » Tue Jun 25, 2013 6:15 am

Hi

Sometimes when a test starts (with open browser), IE does launch but is not in focus. Instead the IE tab on the bottom of Windows (7) is flashing in orange. Therefore none of the next steps actually take place and the test fails.

Any suggestions how to cause the browser to also be in focus always?

NB: there is nothing else maximized on the screen. you see the desktop before the browser is maximized (but not in focus).

:?:

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Getting IE browser to be in focus

Post by Ciege » Tue Jun 25, 2013 4:15 pm

Right after launch, call the .maximize() and .focus() methods on the IE window...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

zivshapira
Posts: 14
Joined: Mon Mar 18, 2013 1:06 pm

Re: Getting IE browser to be in focus

Post by zivshapira » Thu Jun 27, 2013 6:35 am

doesn't seem to always help. OR maybe I am missing something?

1. why does the browser launch not in focus?
2. what is the standard C# code to achieve this?

<browser element>.focus();
<browser element>.maximize();

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Getting IE browser to be in focus

Post by Support Team » Mon Jul 01, 2013 2:06 pm

Hello,

In general, your browser should have the focus when using OpenBrowser().
Do you have any dialog or window that could take the focus?

You could simply call Focus() or Maximize() on the Form object of your browser as shown below:
Form myForm;
Host.Local.TryFindSingle("/form[@title~'Test Automation Tools - Ranorex Automation Framework']", out myForm);
myForm.Focus();
myForm.Maximize();
Another way would be to call these methods on your RepoItem:
repo.TestAutomationToolsRanorexAutomati.Self.Focus();
repo.TestAutomationToolsRanorexAutomati.Self.Maximize();
Regards,
Markus (T)
.
Image