Knowledge Base Article

Home Page > Knowledge Base > Rapise

Home Page > Knowledge Base > Rapise > Rapise Web

Home Page > Knowledge Base > Spira Platform > SpiraTeam

Home Page > Knowledge Base > Spira Platform > SpiraTest

Article Choosing the Web Browser in Rapise from SpiraTest / SpiraTeam

by Adam S on Monday, August 25, 2014

When writing a web test in Rapise you will often want to run the same test script in all three web browsers (IE, Firefox and Chrome). You will want to be able to choose the Test Script from within Rapise when debugging the test and then from a Test Set in SpiraTest when you move the test into production. This article explains the process.

When you write your test script (e.g. MyTest.sstest), you will usually record using a single browser (in this example Chrome). The test script will record the test actions in the main Test() function. In addition, Rapise adds the following boilerplate code to the bottom of the test case:

g_load_libraries=["%g_browserLibrary:Chrome HTML%", "DOM jQuery UI", "DOM GWT", "HTML5"];

this tells Rapise to load the current browser library specified in the global variable g_browserLibrary and if none is specified, use Chrome instead. It also includes code for specifying any additional browser extension libraries to use (when testing apps that use JavaScript frameworks such as jQuery or GWT).

Selecting the Browser in Rapise

When you want to playback the test script in a different browser, you just need to go to the Rapise test settings to change the browser selection:

This dropdown actually sets the value of g_browserLibrary to 'Chrome HTML', 'Firefox HTML' or 'Internet Explorer HTML' automatically. Selecting this dropdown will then provide the appropriate value to the Rapise g_load_libraries command at the bottom.

Selecting the Browser in a SpiraTest Test Set

To set the choice of browser through either the command-line or SpiraTest / SpiraTeam (hereafter referred to as just SpiraTest) you need to use a separate browser variable that you can pass to Rapise to override the selection made in Rapise. We shall use the name g_browser to avoid confusion with the existing variable set in Rapise.

You now need to add the following code to your Rapise test. It should be added to the top of the MyTest.user.js file  and should not be inside any function:

if (typeof(g_browser) != 'undefined')
{
   g_browserLibrary = g_browser;
}


Now if you pass the variable g_browser into Rapise using the command-line or SpiraTest to 'Chrome HTML', 'Firefox HTML' or 'Internet Explorer HTML' it will select the appropriate web browser.

To send this value using the command-line, you would execute the following:

c:\Windows\SysWOW64>cscript.exe "c:\Program Files (x86)\Inflectra\Rapise\Engine\SeSExecutor.js" "C:\Users\adam.sandman\Documents\My Rapise Tests\MyTest\MyTest.sstest" "-eval:g_testSetParams={g_browser:'Firefox HTML'};"

To send this value using SpiraTest you would add the following parameter to your SpiraTest test case (that has the Rapise script linked):

Then in the Test Set you would set this value appropriately:

Now you can run the Rapise test in different browsers.

Putting it all Together

The complete Rapise test script would look something like:

MyTest.user.js

if (typeof(g_browser) != 'undefined')
{
 Tester.Message('g_browser:' + g_browser)
 g_browserLibrary = g_browser;
}

MyTest.js

//########## Script Steps ##############

function Test()
{
 Tester.Message('g_browserLibrary:' + g_browserLibrary)

//========== Recorded at Thursday, August 07, 2014 7:53:03 AM: ======
 //Click on Book Management
 SeS('Book_Management').DoClick();
 //Click on Book Management
 SeS('Book_Management1').DoClick();
 //Click on Author Management
 SeS('Author_Management').DoClick();

}

g_load_libraries=["%g_browserLibrary:Chrome HTML%", "DOM jQuery UI", "DOM GWT", "HTML5", "DOM GWT-Ext", "DOM YUI", "DOM SmartGwt"];



Attachments
Article Info
Last Updated: 8/25/2014
Article ID: KB86
# Views: 2829
Powered by KronoDesk v1.1.0.15 | © Copyright Inflectra Corporation 2011-2016 | Licensed to Inflectra Corporation.