Transactions

Any sequence of interactions or page clicks may be grouped as a transaction. Transactions are mechanics to measure server response time for any operation. In simple words, the use of “Transaction” helps measure the time taken by the system for a particular request. It can be as small as a click of a button or an AJAX call upon losing focus from the text box.

Transactions are added by using the following APIs:

  • ns_start_transaction(“transaction name”); – It acts as a marker to define the start of a transaction
  • ns_end_transaction(“transaction name”,status);  – It acts as a marker to define the end of a transaction

Need for Transactions

Transactions in Script are needed due to the following reasons:

  • To measure server response time for a particular user request /action.
  • To measure server response time for a logical group of actions. For Example, to measure the response time of a checkout having 3 pages, users can group them into a transaction to measure the response time of the group. This is done to enhance our scripts to get the real feel of the end user and the behavior of a real user.

Using Transactions in Script

The user needs to follow the below-mentioned steps to use transactions in the recorded script:

  1. Go to the Script Manager GUI and double click the flow.c file of the recorded script. The flow.c file is displayed. Place the cursor before the main URL and go to File > Insert > Start Transaction.

64

  User can also insert transactions by right-clicking on flow.c file, Insert >Start Transaction.

In C script, Transactions API can be used anywhere in the flow files. The start transaction is normally added before ns_web_url API and the End Transaction before ns_page_think_time API.

Alternatively, start a transaction before the main URL and end the transaction after the URL.

Example:

void Flow1()
{
// Using transaction for home page
ns_start_transaction("HomePage");
ns_web_url("Homepage",   "URL=http://127.0.0.1/tours/index.html");
ns_end_transaction("HomePage", NS_AUTO_STATUS);
}
  1. The Add Start Transaction dialog box is displayed. Enter the Transaction name and click OK.

65

 Note User can use the NS_Variable as a Transaction Name. Need to select the variable also from the drop-down list.

If the Transaction name is a variable, select the check box.

  1. The Start Transaction is added to the flow.c file with the name ns_start_transaction (“Home”) API.

66

  1. To end the transaction, place the cursor before ns_page_think_time API and go to File > Insert > End Transaction.

67

  1. The Add End Transaction dialog box is displayed. Enter the End Transaction name and click OK.

68

 Note User can use the NS_Variable as Transaction Name. Need to select the variable also from the drop-down list.

If Transaction name is a variable, select the check box.

  1. The End Transaction is added to the flow.c file with the name ns_end_transaction(“Home”, NS_AUTO_STATUS).

69

  1. Similarly, add transaction for all other recorded pages of the Script.
  • ns_start_transaction(“Login”);
  • ns_end_transaction(“Login”, NS_AUTO_STATUS);
  • ns_start_transaction(“Flights”);
  • ns_end_transaction(“Flights”, NS_AUTO_STATUS);
  • ns_start_transaction(“FlightResults”);
  • ns_end_transaction(“FlightResults”,NS_AUTO_STATUS);
  • ns_start_transaction(“Payment”);
  • ns_end_transaction(“Payment”,NS_AUTO_STATUS);
  • ns_start_transaction(“Confirmation”);
  • ns_end_transaction(“Confirmation”,NS_AUTO_STATUS);
  • ns_start_transaction(“Logout”);
  • ns_end_transaction(“Logout”,NS_AUTO_STATUS);

Define Transaction

It defines a transaction for starting from a C variable. ns_define_transaction is used to define a transaction (not starting it). This is used when the user wants to start a transaction using a C variable. So, define these transactions such that these names can be added to the hash table.

Adding a ‘Define’ Transaction

  1. Go to the Script Manager GUI and double-click the flow.c file of the recorded script. The flow.c file is displayed. Go to File > Insert > Define Transaction. The Define Transaction dialog box is displayed.
  2. Enter the Transaction name and click OK.

Inline URL Transaction

It is used if a user wants to create an inline URL Transaction.

  1. Select the inline URL and right-click over it.
  2. Go to Insert > Inline URL Transaction.
  3. Enter the transaction name and click OK.
  4. The transaction is added in the inline URL.

Repeat Inline URL

It is used to repeat an inline URL transaction.

  1. Select the inline URL and right-click over it.
  2. Go to Insert > Repeat Inline URL.
  3. Select either the parameter or count and specified the value.
  4. Click OK.

Executing Script from Test Script

Script Testing is useful for quick test of recorded script. By Script Testing, user can easily look at the flow and how the script is recorded. It should be noted that Script testing is not meaningful for those scripts which are taking dynamic values. For example – Account number, Username, Password etc.

  1. To test the recorded script, click the Test Script button on the Script Manager window.

50

  1. The Test Script dialog box is displayed.

3. First, user needs to specify the number of virtual users and number of iterations. Further, there are certain features for users, such as:

  • Fetch / do not fetch inline objects
  • Treat page as transaction or not
  • Simulate a new user on each iteration
  • Run virtual user as Real Browser User
  • Capture Video
  • Continue Session on page error
  • Disable NetStorm Monitors
  • Enable Script based headers
  • Override recorded page think time by specified seconds
  • Scenario profile: The user can use existing scenario profile while executing a test from script management.
  • Run in Debug mode

4. On clicking the Advance Settings button, user is navigated to a dialog box to set the proxy settings and Java settings.

  1. Proxy Settings: Here, user can specify the protocols, such as HTTP proxy/port and SSL proxy/port. User can also set same proxy server for both protocols. For example: proxy.cavisson.com.
  2. Java Settings: Here, user can set the java class path.
  3. Specify the details and click the OK button. Next, user is navigated to the Test Script dialog box, click OK. The script testing is processed and generates a list with time stamp and trace messages.

Verifying Executed Transactions

The executed transactions can be verified in the following ways:

  • Debug Trace Log
  • Progress Report
  • Dashboard GUI 

Verifying Executed Transactions from Debug Trace Log

Figure: Debug Trace Log

Transaction Data in the progress.report

Field Description
Min Min shows the minimum time (sec) taken by the transaction in the whole test.
Avg Avg shows the average time (sec) taken by the transactions in the whole test.
Max Max tells about the maximum time (sec) taken by the transaction in the whole test.
Stddev Stddev tells about the standard deviation in the data (sec) in the whole test.
TOT This field specifies the number of transactions that have been successful out of completed transactions in the whole test.
Detail Transaction Report In this report, there is information about each and every transaction, by name of the Transaction

Verifying Executed Transaction from Progress Report

There are seven transactions added to the script. So, seven transactions should be executed in one session.

72

Verifying Executed Transaction from Dashboard GUI

  1. Open Test Run GUI.
  2. Click on Test Run in Test Run GUI.

Test run GUI

  1. The Dashboard GUI is displayed.

Executed Transaction in Transaction Detail window (in tabular format)

Scripts Debugger

Script debugging feature allows a user to debug the script by adding breakpoint so that the user can analyze or verify the data or flow by printing the value of any variable / step execution to verify the condition.

  1. User can add Breakpoint by clicking on line number in flow file of script.

Note: Breakpoints can be applied on C-type script and CLICK_AND_TYPE script.

  1. For running script in Debug mode, there is an option “Run in Debug Mode”.

  1. Start the test in debug mode.

  1. Following options enabled once test is started in Debug Mode:
  • Continue: Continue command starts the script replay, and then and pauses it on the next breakpoint of the script.
  • Step by Step: The ‘Run Step by Step’ command runs the script one line at a time. This enables the user to follow the script execution. The ‘Run Step by Step’ command starts the script replay, and then and pauses it on the first line of the script.
  • Stop: To stop Debug Test

Note: If a user applies multiple breakpoints in a script and stops the debug trace by clicking the ‘Stop Debug Test’ button before execution of all the breakpoints, then test is stopped immediately and further breakpoints are not executed. The same is reflected in debug trace logs.

Details of Execution while executing Script having Breakpoints.

  1. Debug Trace window for Request/Response & Test Run output details:

6. The user can view NS variable data during execution by right-clicking in flow file of script and selecting View Variable Data.

Variable value data using ns_eval_string

Variable value data in HTTP URL

 Use Cases

Below use cases defines script execution based on the available options, such as Continue and Step by Step. The user first needs to apply the break points in the flow file of the script. Then, run the script in debug mode. Once the script is executed in debug mode, user can use the script replay options (Continue / Step by Step).

Continue

On selecting this option, the script execution is started from the first break point and jumps to next breakpoints.

When user clicks the  icon, the script execution is jumped to the next breakpoint and execute the intermediary steps.

Further, on clicking this icon, the script execution jumps to next break point.

The user can view the script execution report in the lower panel.

Step by Step

On selecting this option, the execution is done line by line. It starts the script replay, and then and pauses it on the next line of the script.

When user clicks the  icon, the execution is performed in sequential manner line by line.

Clicking it further, executes the next line of flow file.

User can view the script execution report in the lower panel.

Note:

  • Shortcut keys to perform the BreakPoint related operations.
    • Continue – F5
    • Run Step by Step – F10
    • Remove Breakpoint – F9
  • The user can remove all the breakpoints in current flow by right-clicking on the flow file and selecting ‘Remove All Breakpoints’ option.

Script Compilation

If there is any syntax error then user gets proper Error message while compiling the script.

Below is a Flow file of script having Syntax Error:

Compilation Error while compiling script having some Syntax Error:

Detail of Errors is displayed on lower panel while compiling script:

Highlighting Missing API Close Brackets in Script Compilation

Earlier, during script compilation if there was any syntax error in multiline API, like if ‘);’ was left in multiline API, NetStorm used to skip that without throwing any compilation error. Now, NetStorm highlights an error for the same.

View Page Details

A user can see Page Detail information, such as URL, Headers, Request and Response, Cookies of recorded script. To view the page details, follow the below mentioned steps:

  1. On the Script Manager UI, go to the View menu and click the Page Details menu item.

2. This displays various details, such as URL, Headers, Request and Response, Cookies, of the recorded pages in the flow files.

3. User can select the flow and page name from the drop-down list. The details are categorized into main URL (with green color) and inline URL (with grey color) and displayed in tabular format according to the selected page, such as path of the main / inline URL, response, host, status code, size of the component (page / image), method, content type, and URL.

The detailed information includes – Raw data, Request body, Response body, headers, cookies, and query string. To view the response of a request, click the View Response check box.