Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Silk4J: When multiple application processes are running, how can you ensure the script attaches to the one it launched?

Silk4J: When multiple application processes are running, how can you ensure the script attaches to the one it launched?

Consider that a number of QA engineers connect to the same Server to develop their tests and run them against the same application throughout the day. At any point a variable number of application windows may be running, so how can each tester ensure that their script finds and attaches to the correct instance of the application i.e the one that it launched?

One possible approach to this problem involves maintaining multiple Object Maps, all of which are identical but tied to separate instances via their Locators; however this approach assumes that the tester knows in advance which instance they need to find and which Object Map needs to be referenced in the script.

If this is not predictable then the Window's Locator will somehow need to be generated dynamically at run-time.

Example: Assume that there are an unknown number Notepad windows running and you need to execute a script that launches and attaches to a new Notepad window.

In order to attach to the last Notepad instance launched, you need to know exactly how many Notepad windows are running. To confirm this you could use a function like the one below which accepts a Locator string and returns the number of windows that match it:

The total returned by the function will match the Index of the last instance and could be used to find it as follows:

However, this Index may not be stable because other windows might open and close while the script is running potentially modifying the indexes of the remaining windows.

The recommended approach is to use the Index to extract a more stable Locator property for the window. For example if we know that the caption value is static and unique, it can be extracted as follows and subsequently used to find and interact with the window:


DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2015-04-30 23:06
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.