SCRIPT RECORDING [webc mode]
GOALS OF TRAINING Script GUI(WEBC MODE) Script generation from CLI Recording Script Structure Page Snapshots Script Testing/Debug trace Script generation from CLI
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 Two ways to generate script are: By nsu_gen_cscript from CLI By Recording from GUI
Procedure To Generate Script From CLI Create an input file named as 1xx.inp. Command for creating filevi 1xx.inp
Do following entries in the file 1xx.imp Enter 1 for Main Url & 2 for Embedded url. Enter the Http method like (GET , HEAD , POST etc) Enter the URL. Example: 1 GET http://www.google.com 2 GET http://www.google.co.in
Command for genrating c script from CLI nsu_gen_cscript -s <ProjectName/SubProjectName> <ScriptName> -F <flowName> -f <InputFileName> Let ::ProjectNameQAT_Trainee SubProjectNameTrainee ScriptNamescript_c FlowNameflow_one InputFileName1xx.inp
Then the command used at CLI to create script in WEBC mode will be:: nsu_gen_cscript –s QAT_Trainee/Trainee script_c –F flow_one –f 1xx.inp Script will be recorded at path:: home/netstorm/work3/scripts/QAT_Trainee/Trainee/script_c
HOW TO RECORD SCRIPT FROM GUI Login to netstorm GUI from browser. Then select script button from GUI. 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,Protocol Category(as WebC).
HOW TO START RECORDING Go to script first
PRESS START RECORDING BUTTON
SCRIPT RECORDER WINDOW Enter the script name “script_web_c”. Enter the URL. Enter the project name & sub project name Either you can choose Project-default,SubProject-default or Contact the Admin to create your own project or subproject Add name of the flow
SCRIPT RECORDER WINDOW
Add The Name Of The Flow
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 Departure City as “New York” and Departure Date will be default. Select Arrival City as “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 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 Credit Card as “12345”. Enter Exp. Date as “2014”. Click on “purchase flight” button.
SNAPSHOT OF PAGE 5
PAGE 6 OF RECORDING This is flight confirmation page. 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 recording click ‘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. Change Page Name GUI can be opened from Edit option-> Page(s). After entering new page names, click change button and then 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 (scripts_web_c) will be shown in script management under your project and sub project.
Add Another Flow In The Same Script Give url and new flow name “flow2” Click here reCORD NEW FLOW AS DESCRIBED ABOVE AND SAVE IT
PART 2 SCRIPT STRUCTURE
SCRIPT FILES exit_script.c flow1.c flow2.c (initially only one flow is generated during recording but multiple flow can be added) init_script.c registration.spec runlogic.c
ADDED SCRIPT FILES
flow1.c All main and embeded urls are shown on this page. Following are added on this page Page think time Transactions Check points
Screen Shot Of flow1.c
Screen Shot Of init_script.c Any declaration can be done here. Transactions can be applied here.
Registration.spec We define all parameters at this page: Such as: File Parameter Search Parameter Random String Parameter Index File Parameter Declare Parameter Random Number Parameter XML Parameter Date Time Parameter Unique Parameter
Screen Shot Of registration.spec
Screen Shot Of runlogic.c Flows of the scripts can be ordered here.
Screen Shot of exit_script.c
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 contains the url whose names are parsed. logs: This file contains Script Recorder_debug.log and script_Recorder_error.log
PART 3 PAGE SNAPSHOTS
SNAPSHOTS OF RECORDED SCRIPT View 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
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 done by the user. Transactions are added by using 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.
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 flow.c file. Ways to put transactions: Click on File option -> Insert -> Start/End Transaction. Right Click on flow.c file, Select Insert -> Start/End Transaction.
TRANSACTION FROM FILE BUTTON
TRANSACTION FROM FLOW.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);
PART 6 CHECK POINTS
CHECK POINT It is very critical to have check points to make sure that we are getting right responses. 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 Go to snap shots options from tool bar Select the page : Right click on frame source/page source Select the unique text which lies only on that page 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
ADD CHECK POINT WINDOW Click on OK button
ANOTHER CHECKPOINT
ADD CHECKPOINT
FRAME SOURCE OF FLIGHTCONFIRMATION PAGE
CHECKPOINTS nsl_web_find(TEXT="<title>Mercury Tours</title>", PAGE=Home, FAIL=NOTFOUND, ID=“ Text 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=“<title>Method of Payment</title>", PAGE=PassengerPaymentDetail, FAIL=NOTFOUND, ID=“Detail 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 are added in registration.spec file of your recorded script
PART 7 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 flow 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 registration file.
FILE PARAMETER It is used to take values from a file created by the user in script. In file parameter you have to define a parameter name and that parameter name can be used in url, 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 seperated by , in UserNamePassword file and save this file
Now goto registration file by double clicking on registration file and right click to insert the file parameters.
FILE PARAMETER WINDOW
ADD FILE PARAMETER WINDOW
FILE PARAMETER ADDED
HOW TO PARAMETERISE Go to the url where username=hello and password=world is written in file. Replace hello with {User} Replace world with {Pass}
PARAMETERISE THE VALUE
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 second page “Welcome” 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 registration.spec file of your recorded script. Right click on this file contents and select Parameters->Search Parameters to add the search parameter.
Right click on registration file & go to search parameter
SEARCH PARAMETER WINDOW
ADD SEARCH PARAMETER WINDOW
SEARCH PARAMETER ADDED
SEARCH PARAMETER ADDED nsl_search_var(SessionId, PAGE=Welcome, LB="name=userSession value=", RB=“>”, RETAINPREVALUE=“YES”);
HOW TO PARAMETERISE SESSION ID Go to the flow1.c file and search the url where “userSession=” value is written. Replace “userSession=” value with {SessionId}
PARAMETERISE THE VALUE
PART 8 SCRIPT DEBUGGING
SCRIPT DEBUGGING Check points Transactions Parameterization 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 script_web.conf
RUNNING WITH 1 USER AND 1 SESSION PROF_PCT_MODE NUM AUTO_REDIRECT 10 0 SGRP g1 NA Internet 0 script_web_c 1 TNAME Test script_web 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 script_web_c 1 “g1”is the group name, user profile is “Internet” , type is Script which is shown by “0”, script_web_c is the Session Name and user is 1. TNAME Test script_web 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 Request & response links will available in page dump under columns Req, RepBody and Rep G_DEBUG ALL 4 Keywords are used to enable debug log
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/script_web.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
TEST RUN NO.
Check the checkbox & click View Reports button
PAGE DUMP Click on Page Dump link
CHECK FOR URL REQ/RES
PART 9 SCENARIO GUI
ADDING NEW SCENARIO FROM GUI Select the Project and Subproject of your Recorded script , for example Training, Script and write the Scenario name as script_web and click on create button.
CREATE SCENARIO
EDIT SCENARIO
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 “script_web_c” and Quantity as “10”
RAMP UP SETTING Double click on “RampUp” phase type and set the ramp up from the given options. Here users are ramped up “simultaneously”
SETTING DURATION Double click on “Duration” phase type and now set the duration of scenario for 20 seconds
RAMP DOWN SETTING Double click on “RampDown” phase type and set the ramp up from the given options. Here 5 users are ramped down per 10 sec
FIX CONCURRENT USER Go to Global Settings, “Fix Concurrent Users” is set by default.
PAGE THINK TIME Go to Group 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 “script_web” and click on “Start Scenario” button to start the scenario.
Following graph represents HTTP request for 1 user and 1 session
REPORTS GENERATED Go to “Analysis” from Netstorm tool bar and click on your Test Run no. Check the Summary Report , Page Dump & Progress Report.
THANK YOU