SCRIPT RECORDING AND PARAMETERIZATION [SIMPLE]
GOALS OF TRAINING Script GUI Script Debugging Recording Script Structure Page Snapshots Script Testing/Debug trace Checkpoints Transactions Parameterization File Parameters Search Parameters Script Debugging Run with 1 U 1 C, 1 U 10 C in debug mode and check request/response files and page dumps
Scenario GUI Designing of Fixed Concurrent Scenario Start Test Page Think Time Session Pacing Execution of scenario Start Test Monitor using Execution GUI and understand all standard graphs Analysis Quick analysis after test is over
Hpd TOURS Its is a dummy application which is used for recording. It acts as a real world application in which the following is done: Sign in where username and password can be anything. Search for a flight to desired destination. Search results are displayed and then any option is chosen. Confirm the flight, give the payment details and then logout.
PREREQUISITE Internet Explorer Version 6.0 or higher Http Analyzer version 5.0 Netstorm Machine IP And Port number. Login Name And Password accordingly with the IP using. NetOcean IP where Hpd Tours application runs. Continued…
If you have Windows Vista OR Windows 7 then you have to disable protected mode of IE for recording. To disable this on IE go to Tools->Internet option ->Security Tab->Select Internet->Uncheck Enable Protected Mode option as shown.
Go through the flow manually using IE before starting the script recording. This will help in understanding the flow which is to be recorded. The flow which is to be recorded is given below.
FLOW OF SCRIPT TO RECORD
PART 1 RECORDING
SCRIPT RECORDING Three ways to generate script are: By Recording from GUI By nsu_gen_script from CLI By making copy of script
HOW TO RECORD THE SCRIPT FROM GUI Login to a netstorm GUI from the browser. Then select script button from the GUI appeared. Click on start button and start recording. First pop up window will open where you have to give Script name, Url, Project and Sub project Name.
HOW TO START THE RECORDING Go to script first
PRESS START RECORDING BUTTON
SCRIPT RECORDER WINDOW Enter the scripts name “ToursTrainee”. Enter the URL . Enter the Project name & Subproject name Either you can choose Project-default,SubProject-default or Contact the Admin to create your own project or subproject.
PAGE 1 OF RECORDING Enter member name “hello” and password “world” and click on “login” button.
PAGE 2 OF RECORDING Click on “flights” button to find the flight.
PAGE 3 OF RECORDING Select the Departure City as “New York” and Departure Date will be default. Select the Arrival City “Paris” and Return Date will be default. Enter No. of Passengers as 2. Select Seating Preference as “Window”. Select Type of Seat “Coach”. Click on “continue…” button.
SNAPSHOT OF PAGE 3
PAGE 4 OF RECORDING Select third option for Flight. Click on “continue…” button.
PAGE 5 OF RECORDING The First Name is “Tiger” and Last Name is “Scott” which are default values. Street Address and City/State/Zip are set by default. First name of Passenger Names is “Scott Tiger” which is default and enter second Passenger Name as “Red Bull”. Enter the Credit Card as “12345”. Enter the Exp. Date as “2014”. Click on “purchase flight” button.
SNAPSHOT OF PAGE 5
PAGE 6 OF RECORDING This is flight confirmation page to confirm your flight. Click on “signoff” button on left side to logout.
PAGE 7 OF RECORDING This is logout page which confirms that you have successfully logout.
FINISHING THE RECORDING To finish the recording click the ‘stop’ button on script management window which will save the script. Stop Recording Button
SAVING SCRIPT
RECORDED SCRIPT PAGE NAMES
PAGES NAMES Above are the default page names which comes automatically from Query String, selecting only the last part of the URL. If two pages have same name then it will be differentiated by pagename_2 for second page, pagename_3 for third page and so on. Example: -FindFlight - FindFlight_2 - FindFlight_3, of recorded script.
Its highly recommended to change the page name after recording . If page names are changed after parameterization or check points it’s a limitation of product that it will not reflect changes in script. If the change page screen gets lost, it can be changed from Edit option-> Page(s). After entering the new page names, click the change button and then the new page names will be saved.
NEW PAGE NAMES By clicking on change button we can change the name of pages.
PassengerPaymentDetail You can directly copy the names from this table to change the pages names. Old Page Names New Page Names index_html Home login Welcome reservation FindFlights findflight SearchResults findflight_2 PassengerPaymentDetail findflight_3 FlightConfirmation welcome Logout
Recorded script (ToursTrainee) will shown in script management under your project and sub project.
PART 2 SCRIPT STRUCTURE
ADDED SCRIPT FILES
SCRIPT FILES script.capture script.detail script.c script.h Dump File Temp File
script.capture Script.capture This file contain main url’s, headers , number of embedded url’s. It contains the main execution loop & the URLs that are accessed by NetStorm. Parameterization and Check Points are added to this file.
SCREEN SHOT OF script.capture
script.detail 2) Script.detail: This file contain detail of embedded url’s of each page. It contains block for each page which has some additional details.
SCREEN SHOT OF Script.detail
script.c 3) Script.c: It contains init_script() and exit_script() to specify start and end of the script. pre_page function and check_page function are added for each page automatically in this file. Transactions are added in this file.
SCREEN SHOT OF script.c
script.h 4) Script.h: This file contain all the headers of a script.
Screen shot of script.h
DUMP FILE 5) Dump File: It contains:- Header file: It contains the request and response of each pages. Index file: It contains URL’s of all the pages. Pages.html PagesList.html
TEMP FILE 6) Temp File: It contains:- changed_url.txt: This file contain the url which name are parsed. logs: This file contains Script Recorder_debug.log and script_Recorder_error.log
PART 3 PAGE SNAPSHOTS
SNAPSHOTS OF RECORDED SCRIPT Snap shot Button
HOME PAGE SNAPSHOT
WELCOME PAGE SNAPSHOT
FIND FLIGHT PAGE SNAPSHOT
SEARCH RESULT PAGE SNAPSHOT
PASSENGER PAYMENT DETAIL PAGE SNAPSHOT
FLIGHT CONFIRMATON PAGE SNAPSHOT
LOGOUT PAGE SNAPSHOT
REQ/RES FROM SNAP SHOT Click on page number of each page from snapshot to check the request and response of each page. You can check the main url’s which are followed by the embedded url’s.
REQ/RES FROM SNAP SHOT
PART 4 SCRIPT TESTING
NEED OF SCRIPT TESTING Script Testing is useful for quick test of recorded script. By Script Testing you can easily look at the flow, how script is recorded. It should be noted that Script testing is not meaningful for those scripts which are taking dynamic values. Example account no., username and password etc.
Go to script management and click “Test Script” button to test the script which you have recorded.
DEBUG LOG
PART 5 TRANSACTIONS
TRANSACTIONS Any sequence of page clicks may be grouped as a transaction. Transactions are added to measure the response time of a particular logical action do by the user. Transactions are added by using following API: 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.
AUTO STATUS Auto Status: In the End Transaction, you should use Auto Status as this will set the status of transaction based on the status of last page which is part of that transaction. If transaction need to be failed, then use error status.
TRANSACTION IN GUI Go to the Script management and double click on script.c file. It should be noted that start transaction should be the first statement within pre_page function block, so take the pointer at that line to insert the start transaction. It should be noted that end transaction should be the last statement, just before the return statement of check_page function block, so take the pointer at that line to insert the end transaction. Ways to put transactions: Click on File option -> Insert -> Start/End Transaction. Right Click on script.c file, Select Insert -> Start/End Transaction.
TRANSACTION FROM FILE BUTTON
TRANSACTION FROM SCRIPT.C FILE
START TRANSACTION (HOME PAGE)
START TRANSACTION ADDED
END TRANSACTION
END TRANSACTION (HOME PAGE)
TRANSACTION ADDED (HOME PAGE)
OTHER PAGES TRANSACTIONS Similarly transactions for other pages, 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);
OTHER PAGES TRANSACTIONS ns_start_transaction("SelectFlight"); ns_end_transaction("SelectFlight", NS_AUTO_STATUS); ns_start_transaction("FlightConfirmation"); ns_end_transaction("FlightConfirmation", NS_AUTO_STATUS); ns_start_transaction("Logout"); ns_end_transaction("Logout", NS_AUTO_STATUS);
PART 6 CHECK POINTS
CHECK POINT It is very critical to have the check points to make sure that we are getting right response. Check Points can be: Positive check point: Searching for expected string. Negative check point: Searching for string which is not expected.
FINDING CHECK POINT Different ways of finding Check Point: Selecting snap shot option from tool bar, will display all pages and then find the unique string for every page. Selecting snap shot option from tool bar, will display all pages and then go to page/frame source to find unique string. Going through dump folder from the script.
HOW TO FIND CHECK POINTS 1) Go to snap shots options from tool bar 2) Select the page : Right click on frame source/page source Select the unique text which lies only on that page only Ex: <title> Mercury Tours </title>
MATCH TEXT FOR CHECKPOINTS There are two options to match the text for checkpoints, which are: Search for specific Text: Select that string which is unique for the page. Search for Text by start and end of string: Select the string whose value is changing dynamically for the page.
CHECK POINTS FROM FRAME SOURCE
FRAME SOURCE OF HOME PAGE
INSERT CHECKPOINTS
CHECKPOINT PARAMETER WINDOW Click “Add” button to add checkpoints.
ADD CHECK POINT WINDOW
CHECKPOINTS nsl_web_find(TEXT="<title>Mercury Tours</title>", PAGE=Home, PAGE=Logout, FAIL=NOTFOUND, ID="Home/ Logout page not found", ActionOnFail=STOP); nsl_web_find(TEXT="Using the menu to the left, you can search for new flights to book.", PAGE=Welcome, FAIL=NOTFOUND, ID="Welcome page not found", ActionOnFail=STOP); nsl_web_find(TEXT="<title>Find Flights</title>", PAGE=FindFlights, FAIL=NOTFOUND, ID="FindFlights page not found", ActionOnFail=STOP);
CHECKPOINTS nsl_web_find(TEXT="<title>Search Results</title>", PAGE=SearchResults, FAIL=NOTFOUND, ID="SearchResults page not found", ActionOnFail=STOP); nsl_web_find(TEXT="Please enter the passenger and payment details", PAGE=PassengerPaymentDetail, FAIL=NOTFOUND, ID="Passenger Payment page not found", ActionOnFail=STOP); nsl_web_find(TEXT="Your reservation has been confirmed. Thank you for booking through Mercury Tours.", PAGE=FlightConfirmation, FAIL=NOTFOUND, ID="FlightConfirmation page not found", ActionOnFail=STOP);
CHECK POINTS ADDED
CHECKPOINTS PLACE Make sure that your checkpoints should be added in the capture file of your recorded script And between the block of //Define Any NS Variables here. Do not remove or modify this line and //End of NS Variable declarations. Do not remove or modify this line
PART 7 PARAMETERIZATION
PARAMETERIZATION Parameterization:- Parameterization is a technique to change the value of the variable at run time. It is achieved through the use of NetStorm variables. Primary use of the NS variables is to parameterize the web_url function in the capture file. NS Variable value is accessed by putting its name within curly braces ({}).
TYPES OF PARAMETERS File Parameters. Search Parameters. Declare Parameters: Not included in this tutorial. Xml Parameters : Not included in this tutorial.
PARAMETERIZATION In this recorded script we will do two type of parameterization: File Parameterization: We will parameterize username and password. Search Parameterization: We will parameterize user session id. We will parameterize them by replacing there values with parameters name within curly braces in capture file.
FILE PARAMETER File parameter:- It is used to take values from the file created by the user in the script. In file parameter you have to define a parameter name and that parameter name can be used in Url’s, Header and Body.
HOW TO ADD NEW FILE To add new file : Select add file button from tool bar, it will add file in the script structure. Add file from CLI which can be any where either in absolute or relative path.
Create new File Button
ADDING NEW FILE Write File Name as “UserNamePassword”
Write usernames and passwords separated by , in UserNamePassword file and save the file.
Now go to capture file by double clicking on capture file and right click to insert the file parameters.
FILE PARAMETER WINDOW
ADD FILE PARAMETER WINDOW
FILE PARAMETERISE ADDED
HOW TO PARAMETERISE Go to the url where username=hello and password=world is written in capture file. Replace hello with {User} Replace world with {Pass}
PARAMETERISE THE VALUE
SEARCH PARAMETER Search parameter:- It is used to search a particular pattern by giving it Left Boundary (LB) and Right Boundary (RB).
HOW TO ADD SEARCH PARAMETER Go to snap shots of your recorded script from script management. Click on first page “Home” Right click on this page snap shot to view the frame source of this page. Select “name=userSession value=” to copy this string as Left Boundary for search parameter from this frame source. Now, go to script management and double click on capture file of your recorded script. Right click on this file contents and select Parameters->Search Parameters to add the search parameter.
Right click on capture file & go to search parameter
SEARCH PARAMETER WINDOW Click on add button to add search parameter.
ADD SEARCH PARAMETER WINDOW
SEARCH PARAMETER ADDED
SEARCH PARAMETER ADDED nsl_search_var(SessionId, PAGE=Home, LB="name=userSession value=", RB=">", ORD=1, SaveOffset=0, RedirectionDepth=Last, Search=Body);
HOW TO PARAMETERISE SESSION ID Go to the capture file and search the url where “userSession=” value is written. Replace “userSession=” value with {SessionId}
PARAMETERISE THE VALUE
PART 8 SCRIPT DEBUGGING
SCRIPT DEBUGGING Checking the script is working correct or not after applying : Check points Transactions Parameterization
HOW TO CREATE NEW SCENARIO Scenario can be created from CLI. Also it can be created from netstorm GUI.
CREATING NEW SCENARIO FROM CLI First login to netstorm machine from CLI. Change directory to work , by: cd work For scenario move to scenario directory and then to corresponding Project and Subproject, Ex: cd scenario/Training/Scripts Create new scenario, by : vi ToursTrainee.conf Enter all the necessary keywords , as below.
RUNNING WITH 1 USER AND 1 SESSION PROF_PCT_MODE NUM AUTO_REDIRECT 10 0 SGRP g1 NA Internet 0 ToursTrainee 1 TNAME Test Tour Trainee SCHEDULE ALL Start0 START IMMEDIATELY SCHEDULE ALL RampUp0 RAMP_UP ALL RATE 120 M LINEARLY SCHEDULE ALL Stabilize0 STABILIZATION TIME 0 SCHEDULE ALL Duration0 DURATION SESSIONS 1 SCHEDULE ALL RampDown0 RAMP_DOWN ALL IMMEDIATELY G_TRACING ALL 4 1 0 0 G_MODULEMASK ALL HTTP G_DEBUG ALL 4 DEBUG_TRACE 1
BRIEF DESCRIPTION OF SCENARIO PROF_PCT_MODE NUM PROF_PCT_MODE is a keyword which distributes users across group, NUM shows that it is distributing users By number. Other options are:- By percentage or Auto mode. AUTO_REDIRECT 10 0 It shows the depth for redirection of page. As we are using search parameter & it takes redirect depth=last by default. SGRP g1 NA Internet 0 ToursTrainee 1 “g1”is the group name, user profile is “Internet” , type is Script which is shown by “0”, ToursTrainee is the Session Name and user is 1. TNAME Test Tour Trainee It is the Test Name.
BRIEF DESCRIPTION OF SCENARIO SCHEDULE ALL Start0 START IMMEDIATELY It means start immediately after scenario begin. SCHEDULE ALL RampUp0 RAMP_UP ALL RATE 120 M LINEARLY User’s ramps linearly with users getting created at a constant inter arrival time at rampup rate of 120 virtual users per minute. SCHEDULE ALL Stabilize0 STABILIZATION TIME 0 This is for stabilizing users . SCHEDULE ALL Duration0 DURATION SESSIONS 1 This is to run the scenario for duration session 1
BRIEF DESCRIPTION OF SCENARIO SCHEDULE ALL RampDown0 RAMP_DOWN ALL IMMEDIATELY Virtual users are ramping down immediately before finishing the test. G_TRACING ALL 4 1 0 0 This is for showing page dumps. G_MODULEMASK ALL HTTP G_DEBUG ALL 4 G_MODULEMASK ALL HTTP & G_DEBUG ALL 4 keywords are used for enabling Level 4 debug logs with HTTP modules. DEBUG_TRACE 1 It creates the debug_trace.log file.
HOW TO START SCENARIO Scenario can be started from scenario GUI, by selecting your scenario from the list. Also scenario can be started from CLI, by: nsu_start_test –n Project/Sub-Project/ScenarioName Ex: nsu_start_test –n Training/Script/ToursTrainee.conf
HOW TO FIND TEST RUN NO. You can find the Test Run No. of your running scenario by following ways: Go to Analysis from the Netstorm GUI and find your Test Run no. by checking your Project, Subproject and Test Name. Or find the Test Run no. of running scenario from CLI by this command: cat /etc/test_run_id
TO CHECK PAGE DUMP Click on analysis button. Click on your test run number.
PAGE DUMP Click on Page Dump option
CHECK FOR URL REQ/RES You can check the Status which should be “Success” and also check the Parameter substitution, Request, Request Body and Response for all the pages.
PART 9 SCENARIO GUI
ADDING NEW SCENARIO FROM GUI Select the Project and Subproject of your Recorded script , for example Training, Script and right the Scenario name as ToursTraineeScenario and click on create button.
SCENARIO SETTING WINDOW
ADDING GROUP & NO. OF USERS To add the group click on “Add Group” button and write Group Name as “g1”, User Profile as “Internet”, Type as “Script” , Session/URL as “ToursTrainee” and Quantity
SETTING DURATION Double click on “Duration” phase type and now set the duration of scenario for 10 minutes
SELECT RAMP DOWN OPTION
RAMP DOWN WINDOW Ramping down 5 user per minute.
FIX CONCURRENT USER Go to Global Settings, “Fix Concurrent Users” is set by default.
PAGE THINK TIME Go to Global Based Settings ,click on “Think Time” and select “Random (Internet type distribution) think time with median of 2 seconds”
SESSION PACING Click on Session Pacing ,select “After the previous session ends” option & write 2 seconds for fixed delay.
PART 10 EXECUTION OF SCENARIO
Click on “Start scenario” button to start the scenario.
STARTING SCENARIO Write the Test Name as “TestTourTrainee” and click on “Start Scenario” button to start the scenario.
MONITORING GRAPHS Click “Execution” from Netstorm tool bar and monitor graphs of your test run. We can also check Test output, Event Log and Transaction Details.
REPORTS GENERATED Go to “Analysis” from Netstorm tool bar and click on your Test Run no. Check the Summary Report , Page Dump & Progress Report.
ANALYSIS Analysis GUI requires lots of analysis for test run which is not included in this tutorial.
THANK YOU