How to create a scenario that finds a window that is hidden or covered by another window?
ScenarioBuilder offers a variety of methods to deal with windows that sometimes are hidden on the desktop. The simplest approach is to use the “Window Actions” Action with the “Advanced Find” property enabled:
This Action, with the Window Action Name property set to “Focus” will bring the window to the front of your desktop, allowing you to perform the next steps in your scenario (click on a button, enter data, activate a link, etc.).
In a load test where many virtual users are connected on a server, conserving resources becomes an issue. In such cases, a less resource-intensive method would be preferable. A “Click On Image” Action can work to bring a window forward, but only if the desired window is partially hidden or overlapped. If a portion of the window can be clicked on, this method will work.
Sometimes the easiest ways are not the answer. That’s where ScenarioBuilder’s flexibility comes in handy. Let’s look at a more sophisticated method of finding that hidden window. Depending on your Windows operating system, combining Alt+Tab or Alt+Esc will toggle through the open windows on your computer. The following scenario uses a Loop Action with Alt+Esc to systematically toggle through all of the open windows on the desktop until the desired window is reached.
Notice Step 1 of the example contains a “Key Down” Action, which is simply a “Function Keys” Action with the “Down” property selected.
Next, note the Loop Action. The first step within the Loop is the pressing of the Esc key, followed by a “Find Image” Action that seeks the “MSN” logo. The Esc key works in combination with the Alt key (which is locked in the “down” position by Step 1) to toggle to the next open window. If the “MSN” logo is found, the Exit Action takes effect, exiting the Loop and continuing to the “keyboardkey_up” Action (don’t forget to include the “keyboarkey_up” Action or subsequent keystrokes may be impaired). If the “MSN” logo is not found (indicating that the desired window is still not opened), the scenario returns to the top of the Loop, where the Esc key is pressed again. In our example, the sequence will repeat up to 10 times, but the loop can be set for as many times as necessary to go through the open windows.
It is necessary to enable the “Continue On Failure” property of the “Find Image” Action (Step 4) so that the scenario continues to loop. If not enabled the scenario will fail the first time the “MSN” logo is not found.
If the hidden window syndrome is only occurring intermittently, the above sequence is best incorporated into a “Continue on Failure” section of the scenario. In so doing, the sequence will only be triggered when the window is hidden. Otherwise it will be bypassed.
Including a “Resume” Action at the end of the “On Failure” section will cause your scenario to return to the point of the failure and resume from that point.