Suppose that you need to do different tasks on different instances of the same window of an application under test.
Our test will search for two different terms, “action based testing” and “testarchitect”, using two different instances of the same web browser and search engine page, in parallel:
Use the “identify window” action
The Microsoft Windows operating environment identifies each form in an application by assigning a handle, or hWnd. You can use hWnd to identify all windows, regardless of whether two or more have same entity settings. Extending on this, TestArchitect provides the identify windows action, which finds all windows matching a given definition, assigns a unique window handle (which includes hWnd ) to each one, and returns those handles to variables:
definition: Name of the definition of which the windows are instances
variable1, variable2, …, variableN: Name(s) of the variable(s) to receive the returned instance identification value(s)
In the given example, assume that we have captured the web page and named the interface definition ‘home’ and textbox ‘search’. We then use action identify windows to retrieve the TA window handles of the two existing browser instances and assign them to two variables, h1 and h2 . These variables allow TA to identify each window with a unique value so that it can interact with each instance properly, entering the first search term (“testarchitect”) into the first window and the second (“action based testing”) into the second window:
In the results below, the syntax used by TA to uniquely identify a window instance is seen in the value of each variable. Note that this TA handle includes the name of the interface definition (“home”).
Hence, as a general case, when there is no need to be concerned that more than one instance of a window of interest exists, it is sufficient to use the TA name of the interface definition (e.g., “home”) for the window argument in any action directed at the window. But for cases in which more than one instance exists, an action’s window argument must contain a TA handle to allow the automation to recognize the specific instance of interest (e.g., “ta name=home, use frames=no, handle=527492”).