+ All Categories
Home > Documents > Scripting Basic Report Execution using LoadRunner

Scripting Basic Report Execution using LoadRunner

Date post: 03-Feb-2022
Category:
Upload: others
View: 14 times
Download: 0 times
Share this document with a friend
21
Guideline Scripting Basic Report Execution using LoadRunner Product(s): IBM Cognos 8 BI Area of Interest: Performance
Transcript

Guideline

Scripting Basic Report Execution using LoadRunner Product(s): IBM Cognos 8 BI

Area of Interest: Performance

Scripting Basic Report Execution using LoadRunner 2

Copyright and Trademarks

Licensed Materials - Property of IBM. © Copyright IBM Corp. 2009 IBM, the IBM logo, and Cognos are trademarks or registered trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at http://www.ibm.com/legal/copytrade.shtml

While every attempt has been made to ensure that the information in this document is accurate and complete, some typographical errors or technical inaccuracies may exist. IBM does not accept responsibility for any kind of loss resulting from the use of information contained in this document. The information contained in this document is subject to change without notice. This document is maintained by the Best Practices, Product and Technology team. You can send comments, suggestions, and additions to [email protected].

Scripting Basic Report Execution using LoadRunner 3

Contents 1 INTRODUCTION............................................................................................ 4 1.1 PURPOSE ..............................................................................................................4 1.2 APPLICABILITY .......................................................................................................4 1.3 EXCLUSIONS AND EXCEPTIONS....................................................................................4 2 DESCRIPTION OF THE TEST CASE TO BE TESTED USING LOADRUNNER ..... 5 3 ASYNCHRONOUS COMMUNICATION IN COGNOS VIEWER .......................... 5 4 FORCING ASYNCHRONOUS COMMUNICATION IN COGNOS 8 ..................... 6 5 RECORDING THE TEST CASE IN LOADRUNNER............................................ 7 6 UNDERSTANDING THE RAW RECORDING PERTAINING TO REPORT EXECUTION............................................................................................................... 7 7 CREATING LOADRUNNER CODE FROM THE RAW RECORDING.................... 8 7.1 CODE FOR “1. CONNECT TO COGNOS 8 VIA A WEB BROWSER.” ............................................8 7.2 CODE FOR “2. LOGIN USING SIMPLE LDAP AUTHENTICATION.” ............................................9 7.3 CODE FOR “3. NAVIGATE TO A REPORT IN A FOLDER IN COGNOS CONNECTION.”.......................9 7.4 CODE FOR “4. CLICK ON THE DESIRED REPORT WHICH IS A SIMPLE LIST. THIS ACTION WILL EXECUTE THE REPORT IN COGNOS VIEWER IN HTML OUTPUT.” .......................................................9 7.4.1 Code for “Issuing the run request for the report.” ................................................ 10 7.4.2 Code for “Handling the async conversation programmatically.”.............................. 10 7.4.3 Code for “5. Click on the Return link to exit Cognos Viewer and return to Cognos Connection.”................................................................................................................. 12 7.5 CODE FOR “6. LOGOFF.”......................................................................................... 13 APPENDIX A: LOADRUNNER PROCEDURES FOR COGNOS VIEWER....................... 14 APPENDIX B: EXAMPLE LOADRUNNER SCRIPT ..................................................... 17

Scripting Basic Report Execution using LoadRunner 4

1 Introduction

1.1 Purpose This document is intended for individuals using LoadRunner to drive Performance, Scalability, and Stability tests for Cognos 8. The topic covered will be the action of executing simple reports in Cognos Viewer. For the scope of this document only HTML output will be discussed.

1.2 Applicability In general, the concepts should be applicable to all IBM Cognos 8 production versions. Specifically, the code examples will be from IBM Cognos 8.4.

1.3 Exclusions and Exceptions The code shown in this document will not necessarily work in every environment for every test case. Cases where there are authored drill throughs, portlets, dashboards, charts, etc, while sharing a lot of the same concepts described in this document, will require specific coding. As Cognos 8 is continuously under development, the code examples and concepts outlined in this document may not apply to post Cognos 8.4 versions of the product. Finally, it is assumed the consumer of this document is already familiar with developing scripts in LoadRunner.

Scripting Basic Report Execution using LoadRunner 5

2 Description of the Test Case to be Tested using LoadRunner

For the purposes of this document, assume the following simple test case has been created and needs to be tested in Cognos 8.

1. Connect to Cognos 8 via a web browser. 2. Login using simple LDAP authentication. 3. Navigate to a report in a folder in Cognos Connection. 4. Click on the desired report which is a simple list. This action will

execute the report in Cognos Viewer in HTML output. 5. Click on the Return link to exit Cognos Viewer and return to Cognos

Connection. 6. Logoff.

Before this Cognos 8 click stream is recorded in LoadRunner a couple key concepts should be covered.

3 Asynchronous Communication in Cognos Viewer

The following is a simplified explanation of asynchronous communication in Cognos Viewer. Asynchronous communication (or async), for the purpose of this document, is between the client (example: web browser) and server (Cognos 8). It is basically a back and forth between the browser and Cognos 8 in which Cognos 8 updates the browser to the current status of the running report. The following two tables describe a simple async conversation between a browser requesting the execution of a report and Cognos 8. Table 1: Communication for a Report that Executes in Less Than 3 Seconds in Cognos Viewer

Client Server Report “run” request is issued Status=”complete” less than 3s

later Report is pushed to client and rendered in Cognos Viewer.

Table 2: Async Communication for a Report that Executes in More Than 3 Seconds in Cognos Viewer (assume report execution time=40s)

Client Server Report “Run” request is issued

Scripting Basic Report Execution using LoadRunner 6

Status=”working” after 3s have elapsed “Wait” response

Status=”stillWorking” after 30s have elapsed. (Note: “stillWorking” will be sent every 30s until the report is complete)

“Wait” response

Status=”complete”, after 7s more. Report is pushed to client and rendered

The reason why this is important to know is that both these cases must be accounted for in the LoadRunner script. For example, a report that runs in less than 3s when 1 user is on the system may run in 40s when 500 users are on the system. Conversely, a report that runs in 6s on a low-end development Cognos 8 environment may run in less than 3s on a production level test environment. The script must be able to handle both cases, more on that later in this document.

4 Forcing Asynchronous Communication in Cognos 8

Cognos 8 comes with the option for the Cognos 8 Administrator to force a report execution request to enter async. This is the desired mode for recording any test case via LoadRunner. This should ensure any request that can go into async will go into async and at least one cycle of the async communication will be recorded by LoadRunner. Steps to enable “Forced Async”:

1. In each instance of Cognos 8, locate the file called rsvpproperties.xml.sample in the Cognos 8 “configuration” directory.

2. Rename it to rsvpproperties.xml. 3. Using an editor, uncomment, and edit the AsynchWaitOverride

property within the file like so. <property>AsynchWaitOverride</property> <value type="long">-3</value>

4. Restart Cognos 8. What this setting does is “sleeps” the run request for 1s longer than the absolute value of AsynchWaitOverride, thus forcing the async conversation to begin for at least one cycle. Note that this is purely a setting to be used for script development purposes and should never be used when performing any actual tests.

Scripting Basic Report Execution using LoadRunner 7

Steps to disable “Forced Async”:

1. In each instance of Cognos 8, locate the file called rsvpproperties.xml.sample in the Cognos 8 “configuration” directory.

2. Rename it to rsvpproperties.xml.sample. 3. Using an editor, comment, and edit the AsynchWaitOverride property

within the file like so. <!--<property>AsynchWaitOverride</property> <value type="long">3</value>-->

4. Restart Cognos 8.

5 Recording the Test Case in LoadRunner

It is recommended that the LoadRunner recording of the test case be done in HTTP/HTML mode and the “General: Recording” option set to “HTML-based script”. The “HTML Advanced” options that are tied to this setting should use the default settings. When recording ensure comments are inserted into the script at record time so it is easier to know what steps were being executed at the time the code was recorded. Some may be tempted to use LoadRunner’s much advertised “Click and Script” technology. While “Click and Script” is not recommended, it may work so if time permits trying it out may be worthwhile. Investigation into using the “Click and Script” recording option for Cognos 8 test cases yielded mixed results. More negative than positive. Anything beyond the most basic of basic test cases won’t work in this mode.

6 Understanding the Raw Recording Pertaining to Report Execution

Even with comments inserted into the code it can be difficult understanding exactly what is going on when a report is executed. Cognos 8 describes a lot of user gestures as “actions”. The following table should assist a scripter to read the generated raw recording. Looking for the following keywords in the raw recording will help explain what has just been recorded. Table 3: Some Cognos 8 Actions Defined ui.action=run Execute a report. (Likely unseen in this

code example.) ui.action=wait Respond to a Cognos 8 status message

of “working” or “stillWorking” ui.action=release Signal to Cognos 8 that the user is

finished with a report. Cognos 8 utilizes a great deal of session related values that change dynamically during script execution. This is important to know since it means that a simple record and playback is not a viable option.

Scripting Basic Report Execution using LoadRunner 8

7 Creating LoadRunner Code from the Raw Recording

The following is an example of turning raw LoadRunner code into code that can be used for testing purposes. Draw from the raw LoadRunner recording to create a workable script. The following code ignores step validation but it should be done on each step of a LoadRunner script so that the success/failure of the step can be tracked. LoadRunner functions such as web_reg_find should be used. Generally, any “EXTRARES” resources can be stripped from the code. Leaving them in could, in certain circumstances, cause undue load on the Cognos 8 system and in almost every circumstance with a few notable exceptions (like with charts and PDF output) the resources are downloaded automatically by LoadRunner anyways.

7.1 Code for “1. Connect to Cognos 8 via a web browser.” This is pretty straightforward. To connect to Cognos 8 a valid URL must be entered using LoadRunner’s web_url function. This can be pulled almost “as is” from the raw recording providing the web server and Cognos 8 virtual directory will not be changing.

// connect to web server

web_url("ConnectToCognos",

"URL=http://{myServer}/cognos8",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t1.inf",

"Mode=HTML",

LAST);

It is very common to parameterize the web server name for portability to other test environments.

Scripting Basic Report Execution using LoadRunner 9

7.2 Code for “2. Login using simple LDAP authentication.” Again, this is quite easy as the recorded function is typically a web_submit_form function with 2 values: username and password. Like above, these are usually trivial to parameterize as required. A successful authentication should likely cause the user’s “Welcome” page to load.

// enter in username and password

web_submit_form("EnterUserCredentials",

"Snapshot=t2.inf",

ITEMDATA,

"Name=CAMUsername", "Value={UserID}", ENDITEM,

"Name=CAMPassword", "Value={Password}", ENDITEM,

LAST);

// load Cognos8 Welcome page

web_url("WelcomePage",

"URL=http://{myServer}/cognos8/mod2_cognos.so?b_action=xts.run&m=portal/cc.xts",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t260.inf",

"Mode=HTML",

LAST);

7.3 Code for “3. Navigate to a report in a folder in Cognos Connection.” So far, so good as this is again an easy chunk of code. Using LoadRunner’s web_link functions are typically the best and easiest approach since no maintenance or changes are required when moving to new Cognos 8 environments. Parameterize the folder name, if necessary.

// click link defined by the Folder name

web_link("NavCC_link",

"Text={folderName}",

"Snapshot=t7.inf",

LAST);

String a group a web_link functions together to complete the folder navigation steps.

7.4 Code for “4. Click on the desired report which is a simple list. This action will execute the report in Cognos Viewer in HTML output.”

Step 4 contains most of the complexity within this test case thus it has been further broken down into two subcomponents.

1. Issuing the run request for the report. 2. Handling the async conversation programmatically.

Scripting Basic Report Execution using LoadRunner 10

7.4.1 Code for “Issuing the run request for the report.” The code behind the following web_link contains the “ui.action=run” command (see Table 3) to tell Cognos 8 to execute the selected report. There is client-server communication information that starts when the “ui.action=run” command is initiated. This is captured in the getAsyncInfo() procedure (see Appendix A). This “async info” is crucial to track properly to avoid negative performance hits and unnecessary errors. If the report is not ready in less than 3 seconds, the async communication loop is started.

// gather dynamic server-client communication info

getAsyncInfo();

// check for a successful HTML report

web_reg_find("Text={validReportData}", "SaveCount=successfulReport",

"Search=All", LAST);

// execute report by clicking on the link defined by reportName

web_link("ClickReportNameLink",

"Text={reportName}",

"Snapshot=t6.inf",

LAST);

// if the report isn’t returned to Cognos Viewer is < 3s start async

if ((atoi(lr_eval_string("{successfulReport}"))==0))

{

/* since the report isn't ready tell the Cognos8 server that we are

"waiting". Keep responding to each server status update as long

as

the server keep responding with the status "stillWorking" */

do

{

sendAsyncWaitResponse();

}while(atoi(lr_eval_string("{statusWaiting}"))==1);

/* loop is exited when a) the status is "complete" or b) an error page is displayed. */

}

The parameter “validReportData” is a piece of information found on Page 1 of the desired report. It should be a piece of data that is extremely unlikely to be found anywhere else but as data in the desired report.

7.4.2 Code for “Handling the async conversation programmatically.” As seen above, this is an example of how one could programmatically tell LoadRunner how to handle async conversation in Cognos 8. Essentially it tells LoadRunner to issue an “ui.action=wait” response to Cognos 8’s status of “stillWorking” (assuming that the report execution is still in progress). As soon as the status is anything other than “stillWorking” the loop can be exited.

Scripting Basic Report Execution using LoadRunner 11

/* since the report isn't ready tell the Cognos 8 server that we are

"waiting". Keep responding to each server status update as long as

the server keep responding with the status "stillWorking" */

do

{

sendAsyncWaitResponse();

}while(atoi(lr_eval_string("{statusWaiting}"))==1);

/* loop is exited when a) the status is "complete" or b) an error page

is displayed. */

The code for the sendAsyncWaitResponse() procedure can be found in Appendix A.

Scripting Basic Report Execution using LoadRunner 12

7.4.3 Code for “5. Click on the Return link to exit Cognos Viewer and return to Cognos Connection.” Within Cognos Viewer, when the user is finished viewing the report they click the “Return” link to exit Cognos Viewer and return to the Cognos 8 portal, Cognos Connection. Clicking the link is a two step procedure. 1. Load the Cognos Connection folder the user executed the report from. 2. Signal to Cognos 8’s Report Service that the user is done with the report.

This step will allow the Report Service to “clean up” resources it had dedicated to this report.

// return to Cognos Connection folder

web_url("ReturnToCognosConnection",

"URL=http://{myServer}/cognos8/mod2_cognos.so?b_action=xts.run

&m=portal/cc.xts&m_folder={returnFolder_guid}",

"TargetFrame=",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t14.inf",

"Mode=HTML",

LAST);

// Signal Cognos8 that the user is finished with the report

web_custom_request("Release",

"URL=http://{myServer}/cognos8/mod2_cognos.so",

"Method=POST",

"TargetFrame=",

"Resource=0",

"RecContentType=application/xml",

"Referer=http://{myServer}/cognos8/mod2_cognos.so",

"Snapshot=t13.inf",

"Mode=HTML",

"EncType=text/html",

"Body=b_action=cognosViewer&cv.responseFormat=successfulRequest &ui.action=release&m_tracking={var_m_tracking}",

LAST);

Scripting Basic Report Execution using LoadRunner 13

7.5 Code for “6. Logoff.” Finally, the code to log off Cognos 8 is back to being quite trivial. This code emulates the user clicking the “Log off” link in Cognos 8.

// log the user off the Cognos8 system

web_url("LogOff",

"URL=http://{myServer}/cognos8/mod2_cognos.so?b_action=xts.run

&m=portal/logoff.xts&h_CAM_action=logoff",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t14.inf",

"Mode=HTML",

LAST);

Scripting Basic Report Execution using LoadRunner 14

Appendix A: LoadRunner Procedures for Cognos Viewer

The following is the code for getAsyncInfo() which captures the initial async information returned from the server with respect to the current running report execution.

/*

Name: getAsyncInfo

Description: procedure that looks for the necessary dispatcher

tracking, conversation and async info for interactive reporting. Works for completely rendered HTML pages.

*/

void getAsyncInfo()

{

web_reg_save_param("var_actionState", "LB=action_state\": \"",

"RB=\"", LAST);

web_reg_save_param("var_executionParameters", "LB=parameters\": \"",

"RB=\"", LAST);

web_reg_save_param("var_ui.conversation", "LB=conversation\": \"", "RB=\"", LAST);

web_reg_save_param("var_m_tracking", "LB=tracking\": \"", "RB=\"",

LAST);

web_reg_save_param("var_ui.cafcontextid", "LB=caf\": \"", "RB=\"",

LAST);

web_reg_save_param("var_asyncStatus", "LB=\"status\": \"", "RB=\"", LAST);

return;

}

The following is the code for getAsyncInfo() which captures any subsequent async information returned from the server with respect to the current running report execution for a report that has entered async. The reason that the getAsyncInfo procedure changes when the report enters async is that the left and right boundaries used in the web_reg_save_param function need to be updated.

Scripting Basic Report Execution using LoadRunner 15

/*

Name: getAsyncInfo_HTMLFragment

Description: procedure that looks for the necessary dispatcher tracking, conversation and async info for interactive reporting.

Works for grabbing async info from server status messages sent as an

HTML Fragment.

*/

void getAsyncInfo_HTMLFragment()

{

web_reg_save_param("var_actionState", "LB=action_state&quot;:

&quot;", "RB=&quot;", LAST);

web_reg_save_param("var_executionParameters", "LB=parameters&quot;: &quot;", "RB=&quot;", LAST);

web_reg_save_param("var_ui.conversation", "LB=conversation&quot;:

&quot;", "RB=&quot;", LAST);

web_reg_save_param("var_m_tracking", "LB=tracking&quot;: &quot;",

"RB=&quot;", LAST);

web_reg_save_param("var_ui.cafcontextid", "LB=caf&quot;: &quot;", "RB=&quot;", LAST);

web_reg_save_param("var_asyncStatus", "LB=&quot;status&quot;:

&quot;", "RB=&quot;", LAST);

return;

}

The procedure named sendAsyncWaitResponse sends a “wait” response to Cognos 8 when it receives a status of “stillworking” from Cognos 8 with respect for a longer running report that has entered async. Since textual report data is pushed to Cognos Viewer when the status reaches “complete” the report validation must be included in this section of code.

/*

Name: sendAsyncWaitResponse

Arguments: This function accepts no arguments.

Parameters: No parameter files are used in this procedure.

Description: This procedure responds to the server's "stillWorking" status with a "wait" response.

*/

void sendAsyncWaitResponse()

{

// track dynamic communication info between the client and server

getAsyncInfo_HTMLFragment();

// validates successful async communication

web_reg_find("Text=&quot;status&quot;: &quot;stillWorking",

"SaveCount=statusWaiting", "Search=All", LAST);

web_reg_find("Text=<xml><state>{ &quot;status&quot;: &quot;", LAST);

// checks for the presence of a completed HTML report.

Scripting Basic Report Execution using LoadRunner 16

web_reg_find("Text={validReportData}", "SaveCount=successfulReport",

"Search=All", LAST);

// this is the client's "waiting" response to the server's

"stillWorking" status update

web_submit_data("WaitResponse",

"Action=http://{WebServer}{Gateway}",

"Method=POST",

"RecContentType=text/plain",

"Referer=",

"Mode=HTML",

ITEMDATA,

"Name=cv.ignoreState", "Value=true", ENDITEM,

"Name=b_action", "Value=cognosViewer", ENDITEM,

"Name=cv.id", "Value=_NS_", ENDITEM,

"Name=ui.action", "Value=wait", ENDITEM,

"Name=cv.actionState", "Value={var_actionState}", ENDITEM,

"Name=ui.primaryAction", "Value=run", ENDITEM,

"Name=errURL", "Value={var_errURL}", ENDITEM,

"Name=executionParameters", "Value={var_executionParameters}", ENDITEM,

"Name=ui.conversation", "Value={var_ui.conversation}", ENDITEM,

"Name=m_tracking", "Value={var_m_tracking}", ENDITEM,

"Name=ui.cafcontextid", "Value={var_ui.cafcontextid}", ENDITEM,

"Name=cv.catchLogOnFault", "Value=true", ENDITEM,

"Name=cv.responseFormat", "Value=data", ENDITEM,

LAST);

return;

}

Scripting Basic Report Execution using LoadRunner 17

Appendix B: Example LoadRunner Script

The following is how a LoadRunner script running the test case in this document may look.

/*

Name: getAsyncInfo

Description: procedure that looks for the necessary dispatcher tracking, conversation and async info for interactive reporting.

Works for completely rendered HTML pages.

*/

void getAsyncInfo()

{

web_reg_save_param("var_actionState", "LB=action_state\": \"", "RB=\"", LAST);

web_reg_save_param("var_executionParameters", "LB=parameters\": \"",

"RB=\"", LAST);

web_reg_save_param("var_ui.conversation", "LB=conversation\": \"",

"RB=\"", LAST);

web_reg_save_param("var_m_tracking", "LB=tracking\": \"", "RB=\"", LAST);

web_reg_save_param("var_ui.cafcontextid", "LB=caf\": \"", "RB=\"",

LAST);

web_reg_save_param("var_asyncStatus", "LB=\"status\": \"", "RB=\"",

LAST);

return;

}

/*

Name: getAsyncInfo_HTMLFragment

Description: procedure that looks for the necessary dispatcher

tracking, conversation and async info for interactive reporting. Works for grabbing async info from server status messages sent as an

HTML Fragment.

*/

void getAsyncInfo_HTMLFragment()

{

web_reg_save_param("var_actionState", "LB=action_state&quot;: &quot;", "RB=&quot;", LAST);

web_reg_save_param("var_executionParameters", "LB=parameters&quot;:

&quot;", "RB=&quot;", LAST);

web_reg_save_param("var_ui.conversation", "LB=conversation&quot;:

&quot;", "RB=&quot;", LAST);

web_reg_save_param("var_m_tracking", "LB=tracking&quot;: &quot;",

"RB=&quot;", LAST);

Scripting Basic Report Execution using LoadRunner 18

web_reg_save_param("var_ui.cafcontextid", "LB=caf&quot;: &quot;",

"RB=&quot;", LAST);

web_reg_save_param("var_asyncStatus", "LB=&quot;status&quot;: &quot;",

"RB=&quot;", LAST);

return;

}

/*

Name: sendAsyncWaitResponse

Arguments: This function accepts no arguments.

Parameters: No parameter files are used in this procedure.

Description: This procedure responds to the server's "stillWorking"

status with a "wait" response.

*/

void sendAsyncWaitResponse()

{

// track dynamic communication info between the client and server

getAsyncInfo_HTMLFragment();

// validates successful async communication

web_reg_find("Text=&quot;status&quot;: &quot;stillWorking", "SaveCount=statusWaiting", "Search=All", LAST);

web_reg_find("Text=<xml><state>{ &quot;status&quot;: &quot;", LAST);

// checks for the presence of a completed HTML report.

web_reg_find("Text={validReportData}", "SaveCount=successfulReport",

"Search=All", LAST);

// this is the client's "waiting" response to the server's

"stillWorking" status update

web_submit_data("WaitResponse",

"Action=http://{myServer}/cognos8/mod2_cognos.so",

"Method=POST",

"RecContentType=text/plain",

"Referer=",

"Mode=HTML",

ITEMDATA,

"Name=cv.ignoreState", "Value=true", ENDITEM,

"Name=b_action", "Value=cognosViewer", ENDITEM,

"Name=cv.id", "Value=_NS_", ENDITEM,

"Name=ui.action", "Value=wait", ENDITEM,

"Name=cv.actionState", "Value={var_actionState}", ENDITEM,

"Name=ui.primaryAction", "Value=run", ENDITEM,

"Name=errURL", "Value={var_errURL}", ENDITEM,

"Name=executionParameters", "Value={var_executionParameters}",

ENDITEM,

Scripting Basic Report Execution using LoadRunner 19

"Name=ui.conversation", "Value={var_ui.conversation}", ENDITEM,

"Name=m_tracking", "Value={var_m_tracking}", ENDITEM,

"Name=ui.cafcontextid", "Value={var_ui.cafcontextid}", ENDITEM,

"Name=cv.catchLogOnFault", "Value=true", ENDITEM,

"Name=cv.responseFormat", "Value=data", ENDITEM,

LAST);

return;

}

action()

{

// increase parameter length from default size of 256

web_set_max_html_param_len("2048");

// connect to web server

web_url("ConnectToCognos",

"URL=http://{myServer}/cognos8",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t1.inf",

"Mode=HTML",

LAST);

// enter in username and password

web_submit_form("EnterUserCredentials",

"Snapshot=t2.inf",

ITEMDATA,

"Name=CAMUsername", "Value={UserID}", ENDITEM,

"Name=CAMPassword", "Value={Password}", ENDITEM,

LAST);

// load Cognos8 Welcome page

web_url("WelcomePage",

"URL=http://{myServer}/cognos8/mod2_cognos.so?b_action=xts.run&m=portal/cc.xts",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t260.inf",

"Mode=HTML",

LAST);

Scripting Basic Report Execution using LoadRunner 20

// click folder link

web_link("NavCC_link",

"Text=myFolder",

"Snapshot=t7.inf",

LAST);

// capture the folder ID for 'myReportFolder' which is used when

Cognos Viewer is exited.

web_reg_save_param("returnFolder_guid","LB=m_folder=","RB=\">myReportF

older", LAST);

// click folder link

web_link("NavCC_link",

"Text=myReportFolder",

"Snapshot=t7.inf",

LAST);

// gather dynamic server-client communication info

getAsyncInfo();

// check for a successful HTML report

web_reg_find("Text={validReportData}", "SaveCount=successfulReport",

"Search=All", LAST);

// execute report by clicking on the link defined by reportName

web_link("ClickReportNameLink",

"Text={reportName}",

"Snapshot=t6.inf",

LAST);

// if the report isn’t returned to Cognos Viewer is < 3s start async

if ((atoi(lr_eval_string("{successfulReport}"))==0))

{

/* since the report isn't ready tell the Cognos8 server that we are

"waiting". Keep responding to each server status update as long as

the server keep responding with the status "stillWorking" */

do

{

sendAsyncWaitResponse();

}while(atoi(lr_eval_string("{statusWaiting}"))==1);

/* loop is exited when a) the status is "complete" or b) an error page

is displayed. */

}

/* ADD CODE TO VALIDATE THAT "successfulReport" HAS BEEN SATISFIED

PROPERLY.

Scripting Basic Report Execution using LoadRunner 21

Essentially if successfulReport>0 then the report execution was

fine. If successfulReport=0 then there was a problem. */

// return to Cognos Connection folder

web_url("ReturnToCognosConnection",

"URL=http://{myServer}/cognos8/mod2_cognos.so?b_action=xts.run&m=porta

l/cc.xts&m_folder={returnFolder_guid}",

"TargetFrame=",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t14.inf",

"Mode=HTML",

LAST);

// Signal Cognos8 that the user is finished with the report

web_custom_request("Release",

"URL=http://{myServer}/cognos8/mod2_cognos.so",

"Method=POST",

"TargetFrame=",

"Resource=0",

"RecContentType=application/xml",

"Referer=http://{myServer}/cognos8/mod2_cognos.so",

"Snapshot=t13.inf",

"Mode=HTML",

"EncType=text/html",

"Body=b_action=cognosViewer&cv.responseFormat=successfulRequest&ui.act

ion=release&m_tracking={var_m_tracking}",

LAST);

// log the user off the Cognos8 system

web_url("LogOff",

"URL=http://{myServer}/cognos8/mod2_cognos.so?b_action=xts.run&m=portal/logoff.xts&h_CAM_action=logoff",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t14.inf",

"Mode=HTML",

LAST);

return;

}


Recommended