Ranorex command prompt causes IE browser to lose focus
Ranorex command prompt causes IE browser to lose focus
My test app runs in an IE browser. If I build my test as a console app, the resulting command prompt obscures the browser (specifically, the first button that gets pressed), and the test fails. Is there any way to a) minimize that command prompt entirely by default, or b) ensure that my browser has immediate focus? I suppose I could put in a mouse-click somewhere else on the page, for a first action, but I'd rather not introduce needless clicks if I can help it. Thanks!
Re: Ranorex command prompt causes IE browser to lose focus
Couple things you can do/try.
1) Send a .EnsureVisible to the IE element at the beginning of your tests.
2) (as you said) click the IE element as a first step.
3) Use a minimize all code snippet at the beginning of your tests (before you launch IE) to verify all windows are minimized. I use this method. Here is the code that does that:
1) Send a .EnsureVisible to the IE element at the beginning of your tests.
2) (as you said) click the IE element as a first step.
3) Use a minimize all code snippet at the beginning of your tests (before you launch IE) to verify all windows are minimized. I use this method. Here is the code that does that:
Code: Select all
//Minimize All Windows
// First we get the type from the Shell.Application
Type typeShell = Type.GetTypeFromProgID("Shell.Application");
// Next we create the object "objShell" from the type "typeShell"
Object objShell = Activator.CreateInstance(typeShell);
// Finally we Invoke "MinimizeAll" to show the desktop
typeShell.InvokeMember("MinimizeAll", System.Reflection.BindingFlags.InvokeMethod, null, objShell, null);
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...
Ciege...
Re: Ranorex command prompt causes IE browser to lose focus
Thanks so much, Ciege - that method did the trick! I have a recording module called OpenBr that opens the browser, and I copied the code snipped into the Init() method of the UserCode.cs for that module. Is that the accepted way of using this code, or is there a more elegant approach I should adopt? Also, am I correct in understanding that you are adding this method as a matter of course to any tests you write?
Re: Ranorex command prompt causes IE browser to lose focus
You are very welcome...
Since I don't use recorded tests or the Ranorex testsuite methodology I can't answer the question about the "accepted" way of doing things for you. But if it works for you then...
And yes, this code snippet is a part of my setup method in my framework that is called by each and every test I develop. So it is called and used by all of them.
Since I don't use recorded tests or the Ranorex testsuite methodology I can't answer the question about the "accepted" way of doing things for you. But if it works for you then...
And yes, this code snippet is a part of my setup method in my framework that is called by each and every test I develop. So it is called and used by all of them.
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...
Ciege...
Re: Ranorex command prompt causes IE browser to lose focus
OK, thanks again for the assistance!