IBM Support

How to close all open IE browsers in an IBM Rational Functional Tester Java script

Troubleshooting


Problem

It is sometimes useful to clean up open browser windows after a test or during error handling. This technote explains a few methods to close all open Microsoft Internet Explorer (IE) browsers in an IBM Rational Functional Tester Java script.

Resolving The Problem

There are many ways to close open IE Browsers, and a script author is not restricted to one of these methods. These are simply a few of the options to choose from.

Method 1: Use the IWindow class to close the Top Windows

This method gets all of the IWindow objects by making a call to getTopWindows. It then sifts through all of the IWindow classes returned to find class names equal to "IEFrame" using the getClassName method on each element of the IWindow array. If the class name matches IEFrame it will close the IWindow, effectively closing out the browser. This option does not require a user to unregister the test objects after completion.

Method 2: Find the TestObjects and explicitly close each browser

This method uses find to get all instances of type "Html.HtmlBrowser" and put them in an array of TestObjects. Once it completes the find, it iterates through the found TestObjects and calls the close method, closing out the browser. Requires TestObjects to be unregistered after they are no longer in use.

Method 3: Find the browser TestObjects and kill the parent process

Similar to method two, this finds all instances of browsers and places them in test objects. Then it gets the process and using ProcessTestObject it will kill the Object. This is not a recommended method as it kills the process without allowing any time for clean up, however, there may be circumstances where this is the best option.


An example of each method can be found attached to this technote. Import the attached file into an Rational Functional Tester Java project and you will find the three scripts in the Library folder.


CloseBrowserExamples.rftjdtr

[{"Product":{"code":"SSJMXE","label":"IBM Rational Functional Tester"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Record \/ Author tests","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"7.0;7.0.0.1;7.0.0.2;7.0.1;7.0.1.1;7.0.1.2;7.0.1.3;8.0;8.0.0.1;8.0.0.2;8.0.0.3;8.1;8.1.0.1;8.1.0.2;8.1.0.3","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
29 September 2018

UID

swg21219258