IBM Support

How to test web application on multiple web browsers concurrently [Examples]

Question & Answer


Question

How do you test web applications concurrently on different web browsers with IBM® Rational® Functional Tester (RFT) Java™ Scripting?

Cause

You need to prepare each browser for testing.

Answer

Examples here use Microsoft® Internet Explorer and Mozilla Firefox. You need to configure the application under test for each web browser vendor. Specifically, in the Application Configuration Tool (Configure > Configure Applications for Testing) you need to have one entry for every web browser that test the same application. For example, you can configure the sample Application htmlTryIt. Then you should see one entry for Internet Explorer and another entry for Mozilla Firefox.





Figure 1. Configuring applications for testing.

There are two possibilities that you can use in your main test script:

  1. One caller script that calls two called scripts

  2. One calling script that calls one called script. This calling script calls the called script with different arguments.



You can call a script with the callScript() method.


Disclaimer
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.


Option 1 - One caller script that calls two called scripts
In this case the code for calling script as follows:


public void testMain(Object[] args)

{


callScript("IE");
callScript("Mozilla");
}


The two called scripts open the application with different browsers.
In this example the script IE.java has the following line:

startApp("HTMLTryIt IE");

and

Mozilla.java contains

startApp("htmlTryIt Mozilla");


Option 2 - One calling script that calls one called script.
The caller script calls the called script with two parameters:
  1. The name of the called script. For example "htmlTryITScript"

  2. The application from the list of the application configuration tool. In this example
    "HTMLTryIt IE" and in the next callScript() "HTMLTryIt Mozilla".


In this way you have effectively startApp("HTMLTryIt IE") and startApp("HTMLTryIt Mozilla"). So the script will open a different browser each time.

The calling scripts uses a string array parameter. It reads the following lines.


public void testMain(Object[] args)
{
String[] browserName = new String[2];
browserName[0] = "HTMLTryIt IE";
browserName[1] = "htmlTryIt Mozilla";
callScript("htmlTryITScript",browserName);
}


The called script returns to the calling script, when it does not see two parameters. If it does get two parameters, it uses a loop to start Internet Explorer first and then Mozilla Firefox.


public void testMain(Object[] args)
{
if (args.length < 2)
{
System.out.println( "Expected at least 1 argument ");
return;
}
else
{
for (int i = 0; i < args.length; ++i)
startApp((String) args[i]);
};

[{"Product":{"code":"SSJMXE","label":"IBM Rational Functional Tester"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Test Applications","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF033","label":"Windows"}],"Version":"6.1;6.1.0.1;6.1.1;6.1.1.1;7.0;7.0.0.1;7.0.0.2;7.0.1;7.0.1.1;7.0.1.2;8.0;7.0.1.3","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
16 June 2018

UID

swg21260955