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=["Web"];
this tells Rapise to load the current browser library specified in the test settings.
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 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
function Test()
{
Tester.Message('g_browserLibrary:' + g_browserLibrary)
//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=["Web"];