You are on page 1of 418
VuGen 8.1 Scripting for Web Student Workbook EDUCATION DEVELOPMENT V@81WEB-STUDENT-O1A MERCURY All rights reserved, All text and figures included ia this publication are the exclusive property of Mercury Interactive Corporation or its licensors, and may not be copied, reproduced, or used in any way without the express permission in writing of Mercury Interactive. Information inthis document is subject to change ‘without notice and does not represent a commitment on the part of Mercury Interactive, ‘This document may also contain registered trademarks, service macks and/or trade names that are owned by their respective companies or organizations. Mercury Interactive Corporation disclaims any responsibility for speeitying which marks are owned by which companies or organizations. Ifyou have any comments or suggestions regarding this document, please send them via Iuipi/www.nere-taining.com/feedback © Copyright 1994 - 2005 by Mercury Interactive Corporation Table of Contents Introduction. Contents of This Course.. Invoke VuGe se About Virtual User Generator (VuGen).. VuGen Workflow Wizard een Sections of Workflow Wizard View VuGen Interface - Tree View. ‘The Planning Phase... The Scenario Creation Phase Performance Test Scenarios The Scenario Execution Phase, ‘The Results Analysis Phase .. ‘The Script Creation Phase. What is a Script? .... Plan Before you Create your Scripts... Business Processes... Documenting User Steps and Input Data Document Business Processes 0 Measure sno. Capturing Business Processes with VuGen .... VuGen and Internet Protocols. Training Application . Resources... Exercises Recording for the Web Script Creation Workflow. Opening a New Script.. Prepare to Record - Set Recording Options. Recording Options - Script... Recording Options - Think Time . Recording Options - Recording Levels. HTML and URL Script Differences... Begin Recording User Steps Perform User Steps for Recording .. Stop Recording... Recording Summiury.. Working with Thumbnails Viewing The Finished Script in Tree View Tree View Icons. Table of Contents Understanding Recording Snapshots... Saving Script... Summary Exercises Replay Script Workflow... Debug Scripts By Running in VuGen What are Script Run-time Settings? ime Settings. me Settings For Basic Script Replay Run-time Settings - Run Logie ~ Run-time Settings - Log.. Run-time Settings - Proxy. Also Set General Option... General Options - Replay General Options - Environment... General Options - Display. Running the Script... Run-Time Viewer Replay Summary... Test Results Window .. Replay Log.. Debugging Tools... Where are the Test Resuits Saved? SuMMALY eons Exercises... Transactions... Script Workflow..... enn What Do Transactions Measure? svoo- mmm Why Add Transactions? vers The Start and End Transaction leon: Use the Workflow View to Add Transactions After Recordin} 1, Make Sure you are on the Transaction Step in the Task Pane.. 47 2. Identify the First Step to be Measured in the Thumbnail Area. 48 3. Click the New Transaction Button 49 4, Select the First Step to add the Start Transaction [eon 410 5. Select the Last Step to Add the End Transaction Icon... Table of Contents 6. Specify 2 Name for the New Transaction .... Transaction Editor... Add Transactions During Recording .. .. Add Transactions During Recording .. sen Add Transactions During Recording - Continued When to Add Transactions’... lene Recommended Transaction Naming Conventions... ‘Check Replay Log......... Automatic Transactions ....... Summary Exercises Parameters Script Workflow, Parameterization... Why Parameterize? When to Parameterize ... Unique Constraint Date Constraint. Data Dependen Data Caching.. . Parameterize In Tree Vi We Parameterize Input Data Steps Parameterize Input Data Steps - Continued Parameterize Input Data Steps - Continued Parameterize Input Data Steps - Continued Parameterize Input Data Steps - Continued .. . Parameterize Input Data Steps Parameterize Input Data Steps - Continued Parameterize Input Data Steps - Continued Parameter Added - In Step Propertie, Create a Date Type Parameter.. Date/Time Formats....... Classroom Discussion ...... Parameter Types. “Eile” Parameter Type - Three Types of Data Sources. Select the Data Access Method for Data File Parameter 1 Sequential Method srs Random Method. Unique (by Row) Method Same Line as Method When Creating Data Files in Notepad . Table of Contents Run-time Settings - Run Logic ee eesesanseee Verifying Correct Execution of the Parameterized Script. Viewing the RunTime Data .. Summary Exercises Auto Correlation After Recording ... Script Workflow Replay of Script Indicates Error. Dynamic Value Recorded . Playing Back Dynamic ValUes..ms Solution - Correlate the Serip Correlation Methods for Web Seriptnnnn About Automatic Correlation After Recording... To Correlate Automatically After Recording 1, Set General Options and Playback non 2. Review the Replay Summary... 3. Scan the Script for Dynamic Values 4, Analyze Correlation Results 5. Correlate the Dynamie Values Alter Correlation. 6. Verify Correct Execution Summary Exercise oo Verification . Workflow .. Functional Integrity for Concurrent Use Test Specification Exampl What Indicates Succes: Visual Cues Indicate Success or Failure of a Business Process. soos Steps Involved in Verification... se ‘What Information Should I Gather for Verification?. va Verification Method About the Text Check Function... Adding Text Check to the Script. Text Check During Recording... Text Check During Recording . Text Check After Recording Text Check Afier Recording, ‘Text Check After Recording. Table of Contents Text Check After Recording. see Verifying Success of Text CheCk on Classroom Discussion... Checking for an Ervor Page... Checking Visual Cue Dependent on Parameter... Add Parameter Name to the Text Check.. Good Practices ses Adding Comments for Text Checkpoint.. SUMMAEY een EX€rCISCS .o.ceseseeeeseees Actions. What is an Action in VuGen? Script Recorded in Single Action. Script Recorded in Multiple Actior Why Record the Script with Multiple Actions?... Relate Planning Information to Actions Classroom Discussion - Planning a Script Create a Script with Actions Correct Initial and End Conditions Record Login In Vuser_init or Not? Action BIOCKS enum Classroom Discussion - Con Action Block Propert ses Weighting - Sequential Access Method... Weighting - Random Access Method Summary. o Exercises, Introduction to Script View... Tree View and Script View ‘The Code Behind the Tree View Icon Closer Look at Web Seript in Script View... Why Use the Script View? Entering Steps or Function in the Script View... Using Insert + New Step Command... Manually Entering Steps.. Using ANSIC....... Example of ANSI C in VuGen Basic C Syntax... ariables and Cos Table of Contents About Variables essen Variable Examples ......-.-.0000 sessonasscusansscdsessecrserersaverersnoness ws sesceeee O14 About Constants C Operators, Statements, and Functions C Operators Supported by VuGen - Examples Commonly Used C Statements in VuGen.. The “if” Statemen ‘The ‘for’ Statement Commonly Used C Funetions in VaGen . C String Functions in VuGen. C Data Type Conversion Functions VuGen Output Message Function Format Codes for Ir_output_message Basic Script Debugging... Finding Syntax Errors Adding Breakpoints Executing Single Steps SUMMALY soon Exercises .. Advanced Scripting Techniques... Function Libraries for Load Testing .nonn General LoadRunner Functions Irabort. Trexit wee. Ir_save_string .. Ir_save_date_time ose Using Offser in Ir save date_tim Ir_advance_param Ireval_stri Ir_get_autrib_string. Protocol Specific Functions. Web_reg_save_param ‘Web_reg_find.... Summary Exercises .....0 Manual Correlation .. Why Perform Manual Correlation?. Manual Correlation Steps... 1. Play Back the Script with ‘Data returned by server’ Table of Contents | a - Investigate the Error in the Replay Log. wo IS Lb Test Results Reveals the Problem... 116 2. Determine the Step That First Gets the Dynamic Value. 7 3, Determine the Value to Correlate .. sess 11-9 Classroom Discussion... sos 1-10 4.a Switch to Recording Snapshot Met 4.b Search For the Dynamic Value..... 11-12 4c Create a Parameter... M13 5. Parameterize Each Occurrence of Dynamic Valve -Me14 Parameter ized the Dynamic Value - Tree View .. Parameterized the Dynamic Value - Setipt View ... HAIG Review web_reg_save_param Function . 1-17 Where Did the web_reg_save_param Get Added? oMN-18 6. Verify Correct Execution 11-19 ‘Summary... 11-20 Exercises... 11-21 Auto Correlation During Recording When to Correlate During Recordi About Automatic Correlation During Recording Which Correlation Method to Use Automate Correlation During Recording. 1, Enable Correlation 2. Create New Application 3. Create a New Rule 3. a. Defining Properties for the New Rule. 4. Test the Rule ... Regenerate the Script... Or Record a New Script.. Another Approach for Creating Rules... Export and Then Import Rules... Export Rules - Select the Rule(s) to Export. Export Rules - Save with .cor File Extension ... Import Rules - Select the Rule File..... Summary. Exercises Advanced Error Handling. rnnennnne Web Server Sends Status Code on Error. Web Server Constructs a Custom Error Page Available Solutions. Table of Contents Advantages of ContentCheck... Handling an Expected Error with ContentCheck . sevnennnnnnsnnsnsn Suffix: "statement”Generate web_reg_find functions for page titles .....nnenenee IT Logging on Demand, Only Errors Will Generate Log Viewing Error Snapshot in Controller . Error Snapshot in Coniroller.. Summary Exercises Optional - Prepare For Load Testing. Verify Seript Functionality .. Run-time Settings - Pacing... Classroom Discussion - Pacing Run-time Settings - Miscellaneous Using Ir_continue_on_error. Use Caution with Ir_continue_on_ervor. Run-time Settings - Speed Simulation Run-time Settings - Browser Emulation ‘Adding Additional Files to the Script NEXt StePS wu Manual Correlation - Steps 1. Play Back the Script with “Data returned by server’. 1.a Investigate the Envor in the Replay Log .. 1.b Test Results Reveals the Problem 2, Compare Scripts with WDiff AG 2.a Which Values Need to be Correlated vnennnnnsennnnseecee AT 2.b Copy Just the Dynamic Value... AB 3. Find Left and Right Boundaries. a Ao Determine Where 10 add the Correlation Function. 4, Add web_reg_save_param Function.. 5. Parameterize the Dynamic Value in the Seript Every Time it Occurs 6. Verify Correct Execution .. When to Correlate and When to Parameter Summary Exercises Table of Contents Introduction Introduction Course Objectives After completing this chapter, you will be able to: Create scripts for performance testing Understand the fundamentals of VuGen code Understand when, why and how to use: — Parameterization — Content Check — Correlation = Advanced Error Handling Create soripts that are maintainable for long periods of time. 11 Introduction Contents of This Course DAYL * Lesson I = Introduction * Lesson 2 — Recording for Web. * Lesson 3— Replay * Lesson 4 — Transactions © Lesson 5 — Parameters * — Lesson 6 - Auto Correlation - After Recording * Lesson 7 - Verification * — Lesson 8 — Actions DAY2 * Lesson 9 — Intro to Script View * Lesson 10 Advanced Scripting Techniques * ~~ Lesson 11 ~ Manual Correlation * Lesson 12 - Auto Correlation Before Recording * Lesson 13 - Advanced Error Handling * Optional Lesson — Prepare for Load Testing These materials are intended for anyone who creates or edits the scripts needed to load test with LoadRunner. Both introductory concepts like recording and transaction definitions, as well as advanced topics like maintainability, correlation, and custom coding are covered. Note: When completing labs, be aware that all input appears in courier font and button/icon titles appear in SMALL CAPS. 1-2 Contents of This Course Introduction Invoke VuGen ITF Vato Use vert Select a protocol to create a new script. ——S To create a new script in a pr —_— click New Vuser Script button. T aD setts J. ¢ MERCURY LOADRUNNER — APPLICATIONS VIRTUAL USER GENERATOR. This will open Virtual User Generator Start Page. This page gives you couple of options to create or open a script. a) To create a new script using a recent protocol, click the protocol in the RECENTLY USED PROTOCOLS list. b)_ To open an existing script, not in the recent list, click OPEN EXISTING SCRIPT button, ©) Tocreate a new script in a protocol that is not listed, click New VUSER SCRIPT. Invoke VuGen 1-4 Introduction Use VuGen to develop scripts by recording a user performing typical business processes ‘on aclient application. VuGen creates the script by recording the activity between the client and the server. For example, in browser-based applications, VuGen launches the browser and traces all HTTP requests (assuming HTTP is the protocol selected) sent to and received from the web server. We do not need to write a VuGen script. Rather, by simply navigating the steps in the business process just as a real business user would, VuGen records those user actions, and generates the script based upon those actions. Invoke VuGen Introduction [reece TNT nis Deo 71B! eamsent > 9 01 91s 19 if) ee me | sur omen Introduction to Seript Creation 2 Verification 3. Enhancements 4, Prepare for Load Figure 1-2 Virtual User Generator Virtual User Generator, or VuGen, is used to create scripts that are used with LoadRunner and Performance Center. During web recording, VuGen invokes the browser and “hooks” into the HTTP communication layer. HTTP (Hypertext Transfer Protocol) is the protocol that web clients and web servers use to communicate with each other, By means of these communications hooks, VuGen captures the communication between the browser and web server. VuGen generates a script from this process. After or during recording. scripts can be enhienced by: * Verifying that the Business Processes succeed by adding content check © Inputting custom dynamic data to solve playback problems. * Capturing and reusing data found during playback * Adding business logic to accomplish complex Business Process tasks. About Virtual User Generator (VuGen) 15 Introduction VuGen Workflow Wizard eR Men Peet We Blan lose noe efrler|M lemma + su al gli le stron Introduction to Script Creation senievamerr 1. Recording 2. Verification Yrscrn | een 3. Enhancements, | “AMrenmetertsed + Adfvhsnelnn Contre chess 90d porate Seton 4, Prepare for Load 7 ee ee you ceases ine ite Figure 1-3 Workflow Wizard ‘The new script opens with the Workflow Wizard. VuGen's WoRKFLOW WizaRD walks you through the different steps of creating a script. It guides you at cach step of the script creation phase and as such is the recommended view for new users, who can read and edit the script with ease, ‘The left pane of the WORKFLOW WIZARD shows a list of the tasks required in order to create a script. Clicking on any stage within the task list opens that step in the WorkFLOW WIZARD. The NEXT button at the bottom moves you to the next step of script building. VuGen indicates the current task with an arrow in the TASKS pane. Day One will focus on the WORKFLOW WIZARD view and TREE VIEW. 1-6 \VuGen Workliow Wizard Introduction Last Replay Summary Resut iratony results seplay Stats: No errors detected [2° orratn Pan Verification: Fert ei slay Anan Figure 1-4 Workflow Wizard View Details Note: Figure 1-4 shows VuGen after the script has been completly developed and replayed. ‘This screen shows replay summary, recorded and replayed snapshots, and the task list on the left, VuGen’s left pane shows a list of the tasks required in order to create « script in the Task Pane. The task list guides you to the next step in step creation, Clicking on a task provides more info on the Information pane. Sections of Workllow Wizard View 17 introduction VuGen Interface - Tree View This screen shows a set of recorded actions in the Icon: [Bees Demet | caste Tree View “tnt Qintao ee lcon-based Tree View Snapshot View Boma 2k « [Output Window } Figure 1-5 VuGen Interface - Tree View wased TREE VIEW, corresponding screen-shots in the Snapshot View, and a REPLAY LOG at bottom in the Output window. 18 ‘The TREE VIEW shows a representation of what the client sent to the server. The Snapshot View displays the Page View which is a representation of what the client received from the server for the highlighted step, \VuGen Interface - Tree View Introduction The Planning Phase ca Anatyze oyster, Cather eyeter, ‘age data Figure 1-6 Load Testing Workflow with Planning Steps Planning Consists of: lL. Det ne load testing goals. Analyze system under test. 3. Gather system usage data. Planning an effective load test was covered in the Fundamentals af LoadRunner course, Note: Planning should be completed before you start recording. Tho Planning Phase 19 Introduction The Scenario Creation Phase (==) 2s reste scanaion Seaed on your seule Figure 1-7 Scenario Creation Step ‘Once generated with VuGen, the script is assigned to a scenurio, Scenarios define the execution of a load test, While creating a scenario, apart from the script, you define which host machine will generates the load, and how many virtual users are going to run the load test. Scenarios are designed in the Controller. You also define the scheduling and performance monitors for the scenario, LoadRunner users judge performance based on reports of LoadRunner vs. expected/defined load testing objectives, Users can take this data to identify the root cause of problems and application design issues to be prostctive in enhancing application performance. Scenario creation is covered in the Fundamentals of LoadRunner course. 1-10 ‘The Scenario Creation Phase Introduction Performance Test Scenarios AA scenario is a file that defines the scripts to execute, the number of Vusers to run, the goals of the test, the computer that will host the Yusers, and the conditions under which to run the load test. Elements of a Scenario Figure 1-8 Performance Test Scenarios A performance test scenario defines the events that occur during each testing session. For example, a scenario defines and controls the number of users to emulate, the scripts to run, the load testing goals to achieve, the machines on which they run their emulations, and the settings with which they will run the load test. Vuser is the term given to the emulation of End User Business Processes against a given application. Each iteration in a VuGen seript performed by the Loud Generator is called a virtual user or "Vuser.” Vuser generate load on the application under test, This data is used by Business Experts, IT personnel and Business Executives to evaluate their application’s scalability and performance under load, Pertormance Test Scenarios 1-11 Introduction. The Scenario Execution Phase Figure 1-9 Scenario Execution Step Once the scenario is defined in the Controller the next step is it, When you run a scenario, LoadRunner generates load on the application you are testing, and measures the system's performance, Scenario execution involves: 1, Debug Run 2. Isolate Top Time Transaction 3. Full Load Test 4, Scalability Test 112 The Scenario Execution Phase Introduction Tweak ‘Application one Aoaizeronate | | Fine tne ayer ats print |_| beved on annals bottenscts | deteand ern Figure 1-10 Results Analysis Step LoadRunner Analysis provides multiple perspectives on site performance that help identify bottlenecks. The key benefits of LoadRunner comes from its powerful Analysis module, Using the Analysis module in conjunction with backend monitoring tools, performance testers can examine performance in depth and isolate bottlenecks and slowdowns. ‘The Results Analysis Phase 1-13 Introduction The Script Creation Phase Figure 1-11 Script Creation Step Creating a script using Virtual User Generator (VuGen) Creating a script is as easy as pressing ‘Play’ on a VCR-style control panel and performing the actions in the browser window that you want Virtwal Users to emulate during the test. This simple script can be enhanced for dynamic data input, logical branching, and so on Note: In this course, the emphasis will be on creating scripts for a web application. Steps Involved in Creating a Script: L 2 Recording user actions Adding LoadRunner Transactions Parameterizing input data Adding verification checks Correlating reused data Verifying correct execution of the script ‘The Script Creation Phase Introduction What is a Script? * A Script emulates the steps of real users using the application. A VuGen script, also known as a Virtual User (vuser) or Transaction File, is the recorded user actions captured by Virtual User Generator. © When played back, the file interacts with an application just like a real user. In a Joad test, datu from this interaction is reported back to LoadRunner Analysis allowing for systematic diagnosis of the root cause problem. © The script file itself is a ANSI-C script file that supports all programming, conventions available to the C programming language, as well as functions specific to VuGen scripts. What is a Script? 1-15, Introduction Plan Before you Create your Scripts Gather rotevant | tast information ils Figure 1-12 Planning There are four phases in Script Creation. The first is planning, where Business Processes are identified as critical. common, high traffic or revenue-driven, Planning is covered in the Fundamentals of Loadunner course 1-16 Plan Before you Create your Soripis Introduction Business Processes | For an auction site the typical business processes are: + Browse * Bid * List items for selling * Search For an news site the typical business processes are: er + Using streaming media to Iisten to aude media see video media * Search Figure 1- 3 Examples of Business Process Think of Business Processes as a set of steps a customer takes to accomplish something. In the real world you might stand in line at a bank, then fill out a deposit slip and hand the teller some money to make a bank deposit. Each step is a user uetion, and one or more similar computer-based steps that can be emulated by VuGen. For LoadRunner or Performance Center, identifying business processes is crucial to designing realistic load test scenarios. Load generators run the business processes as part of a scenario and are scripted using the Virtual User Generator. Take a moment to identify several Business Processes on a common web application such as a news portal, search engine or auction site. Business Processes 1-17 Introduction Documenting User Steps and Input Data ‘Steps for sign-in Input data View the sign-in screen Type username and —_| username: [mercury password password: |test Click on Sign-In button Wait for confirmation Figure 1-14 User Steps and Input Data In the planning stage, you would document the user steps and input data for the identified business proc: Since a business process is really just a series of steps, some of the steps require the user to input data, For instance, logging in to a Flight application usually requires two input steps and a button push, Additionally, the input data must be recognized as valid in order for the process to sueceed. Document each step of each business process you selected for recording. Documenting, these steps precisely is important for recreating the business process and will help you note data sources, transactions and response times. Kdeally, input data should be documented in the planning phase before recording, User input is one of the more difficult user actions to emulate in a script. Some steps, require specific input such as a valid password, Other steps require unique input every time the business process is executed. 1-18 Documenting User Steps and input Data Introduction Document Business Processes to Measure How can | isolate STEP 4 Start application STEP 2 STEP ‘STEP 4 STEPS | Solect departure and arrival cities ‘Type username and password Click on Sign-In button Wait for confirmation ‘STEPS | Enter dates ‘STEP 7 | Enter credit card details STEP 8 | Click on Submit Figure 1-15 Evaluating Business Process A scripted sequence of End User actions alone will not evaluate a Business Process. To have the emulated Busi ‘Transactions must be added to the script. 1ess Process be evaluated by the LoadRunner, VuGen ‘VuGen Transactions are simple statements added to the script that tell the LoadRunner Scenario when to start and stop measuring application responsiveness for a series of End User actions. The Transactions become data points in the LoadRunner Analys Document Business Processes to Measure ‘stem. 1-19 Introduction Capturing Business Processes with VuGen the number for events stops ara geting recorded Figure 1-16 Recording User Steps in VuGen VuGen is the primary tool used to create scripts that generate performance data in a LoadRunner load test. VuGen produces the script by capturing the data through a user-step recording process. When prompted, VuGen will open a web browser and “listens” to the actions taken by the person performing the recording. These actions are automatically translated into a VuGen script. This recording process is discussed in Chapter Two, Recording for Web. Keep in mind that while web scripting is covered by this course, many other types of platforms and environments can be scripted with VuGen, 1-20 Capturing Business Processes with VuGen Introduction VuGen and Internet Protocols © The Internet Protocol Suite (TCP/IP) is used for browser-based as well as other ‘common Business applications. Individual components of TCP/IP include HTTP, HTTPS, Telnet, SMTP, FTP, and SSH. VuGen records end user actions by watching the network traffic passed between the end user application and the target application server through the use of a proxy, HTTP and HTML are crucial technologies for VuGen script writers. A study of these technologies is recommended for anyone who creates and manages LoadRunner script files. \VuGen and Internet Protocols 1-24 Training Application SL stn 4.2008 4 epee vets cnn Paces: | => Introduction Before you access the training application: Invoke the Apache Server (Start> Programs > Mercury Tours > Start Server) Figure 1-17 Mercury Tours Training Application ‘The Mercury Tours training web te is one of the training applications used for the lab exercises in this course, This application is hosted on your PC and can be found at hup:/ilocathost/servlet!com.mercurytours.serviet, WelcomeServlet, Make sure that the Apache Web server is invoked before the application is accessed To invoke the Apache Web Server: START + PROGRAMS — MERCURY TOURS > START SERVER Note: The Mercury Tours URL is case sensitive. When working with the exercises, make sure that you enter the URL correctly 1-22 Training Application Introduction Resources © Books online = VuGen User's Guide and Function Reference © Student materials — Student book, tips and tricks * _http://support.mercury.com = World-wide user community of 23,000+ = Self Help Features = Mercury Knowledgebase (thousands of solutions} * Customer knowledgebase * User discussion forun thousands of solutions each quarter) — — Submit/update/track support cases online — Patches & service packs — Product alerts and announcements: = Company promotions and customer reward program Online help files can be found under the Help button in the upper right hand corner of the VuGen window. The student book is also a good future reference. Can be used as a reference if you want to go through the exercises a second time. The training application and how to sctup the training application is available at www.mere-training site ‘The Support web site is an excellent resource - Mercury was the first testing company to be awarded Support Center Practices certification, and has also been winner of the SSPA (Service & Support Professionals Association) WebStar Service award for several years running. The support site contains a wealth of information and discussion, product patches, and documentation. Resources 1-23 Introduction Exercises Objective: 1. To get familiar with the Mercury Tours application, 2. To make sure that Mercury Tours is available for the later exercises. 3. To get familiar with the VuGen and how to navigate. Part 1: Preliminary Setup 1. Start the Server a) From the Windows START menu —> PROGRAMS — MERCURY TOURS > START SERVER. b) Verify that the Start Server window displays the following line: Rpache/i.3.17 Apachevserv/1.1,2 running After verifying, minimize the window. Note: ALWAYS use Stop Server (either from the Desktop icon or START — PROGRAMS — MERCURY TOURS) to stop the Apache web server. If you shut it down some other way, unexpected results will probably occur. Part 2: Get to Know Mercury Tours 1, Start the browser. 2. Bring up the Mercury Tours web site, a) Inthe URL space, type: rylets/com.mercurytours..sarviet This is the URL is for the training web site. Note: As indicated earlier in the lesson, this URL is case sensiti b) Press ENTER. 3, Test account information. a) Sign in with User Name joo and Password bean, b) Log in should be successful and no errors should be reported. If los successful, let your instructor know 1-24 Exercises Introduction. 4, Purchase a flight ticket. a) In the browser, enter the flight details to search for available flights. ‘Accept the defaults for sll fields on the FLIGHT FINDER page except those shown in the table below. FIELD VALUE, | Departing From San Francisco Arriving In New York b) Click CONTINUE. ¢) Inthe browser, accept the default flights for both directions of the round trip. By default, the first available flight is already selected for each direction when the SELECT FLIGHT page appears. d) Click the CONTINUE button. ©) In the browser, type in the required passenger and credit card information. On the BOOK A FLIGHT page, fields which require data entry have red labels. Enter the passenger name and credit card number, Use data from this table. FIELD VALUE | First Name Joseph Last Name Williams Number 987654321 f) Click SECURE PURCHASE. 5. End the business process by signing off from the web site, In the browser, click the SIGN-OFF button located near the top of the page and do not click the log-off button. 6. Close the browser. 7. Make sure that you do not close the Apache Server. Part : Navigate within VuGen 1. Invoke the Virtual User Generator (VuGen). Exercises 1-25 1-26 Note: If you were in TREE View when viewing the previo Introduction a) START — PROGRAMS —> MERCURY LOADRUNNER — APPLICATIONS VIRTUAL USER GENERATOR. b) Wait for VuGen to open. Create anew script. Gf a) Click SCRIPTS tab, b) On the START PAGE under Scripts tab, click the NEW VUSER SCRIPT button, or select FILE — New from the VuGen menu. The NEW VIRTUAL USER dialog box opens c} Select NEW SING and click OK. f PROTOCOL SCRIPT and select WEB (HTTP/HTML), 4) This opens the script in a new tab and INTRODUCTION To ScRIPT CREATION page gets displayed. script. Opening a new script will cause VuGen to open the START RECORDING dialog box, If this happens then click CANCEL and move on to step three, 3. Make sure that only the TASKS button is selected. If you see TREE or SCRIPT buttons selected then click on RETURN TO WORKFLOW at the bottom of the task list, this indicates that you are in the WORKFLOW view. Na Select Tasks button Click the NEXT button at the bottom left under the task list. This moves you to the next task, Keep clicking the NEXT button to move around and pay attention to the different tasks that the NEXT button takes you to. Click on the TREE View button. This opens the TREE View with the task list displayed on the left Note: You have both the TASKS and TREE View button selected, Script Tasks || a Select TREE VIEW button, Exercises Introduction 7. Clicking the TASKS button again will hide the task list and provide more space in Tree VIEW. Clicking back on the TASks button will bring up the task list. 8. To go back to the WORKFLOW View, make sure that the task list is displayed, click on the RETURN TO WORKFLOW button at the bottom left under the task list. Or clicking on any task on the task list will take to back to that task in the WORKFLOW VIEW. Note: If you have recently replayed the script then you will see a BACK TO REPLAY SUMMARY button instead of RETURN TO WORKFLOW button, 9. Close the Script and VuGen. a) FILE > Chose, Closes the script. b) FILE Exit. Closes the VuGen, Exercises 41-27 Introduction 1-28 Exercises, Recording for the Web Recording for the Web Objectives After completing this chapter, you will be able to: Record a VuGen script based upon requirements. Create a VuGen script by recording user steps with the Virtual User Generator for web environment. Describe the HTML and URL recording levels. 24 Recording for the Web Script Creation Workflow —@)— Record Record a Web Vuser Script Figure 2-1. Seripting Creation Once identified, the Business Processes must be recorded in VuGen, During recording, the Business Process will be followed as if by a normal end user. These actions are recorded by VuGen along with any server-to-client and client-to-server communication, After recording, the script may be enhanced te include Transactions, Verification, Parameters and Correlated data, Script enhancements will be discussed later in the course. After a script has been recorded and enhancements have been added, the script must be tested to verify that it will run correctly and measure the Business Process accurately. ‘This chapter will focus on the second phase of the script workflow, Recording 2-2 ‘Script Creation Workflow Recording for the Web Opening a New Script ET i Ree z s a ———- ————————s lps (2 Semen pas : 3 Figure 2-2 Opening a New Script L. The first step to recording is to invoke VuGen, Select START > PROGRAMS > MERCURY LOADRUNNER — APPLICATIONS -> VIRTUAL USER GENERATOR. Once VuGen is invoked, configure the recording session: Select FILE — NeW or click the NEW VUSER SCRIPT button on the START PAGE, tab. The NEW VIRTUAL USER dialog box opens. 3. Select “NEW SINGLE PROTOCOL SCRIPT” from the NEw VIRTUAL USER dialog. box. 4, Select a protocol from the list box. Selec: "WEB (HTTP/HTML),” and click the right arrow to move the protocol to the SELECTED PROTOCOLS box, 5. Click OK, o This opens the script in Workflow Wizard view with the tasks listed on the left Opening a New Script 2-3 Recording for the Web Prepare to Record - Set Recording Options eer About Rece tahacamett tions Sree: — SE ee 6 see _ ee Exe Recording Options seecten Figure 2-3 Accessing Recording Options Before you start recording, itis important to customize your recording session by configuring RECORDING OPTIONS. This configuration helps to specify the information to record, the browser or client with which to record, and to designate the content for your seripts. Once VuGen is invoked, configure the recording session: 1. Make sure you click on the RECORDING task and the RECORDING APPLICATION substask, 2. Click the RECORD OPTIONS button Por click on the OPEN RECORDING OPTIONS link and configure the recording options for this session, then click OK. Note: RECORDING OPTIONS needed for this chapter will be discussed in detail on the following pages. In the coming chapters, we will discuss more recording options as we need them. 2-4 Prepare to Record - Set Recording Options Recording for the Web erat Se = Soca ene ‘oven Foe | Te oon Contaan i Fa " | cements Oy crt ac > Bo renee sae | BP Fre grcesses esd os Combes Deseo ae ALT peesses whan ong tps ———— [ ponent cane ay eaten ie scsi when Yuen to eeriog Le Figure 2-4 Script Node Before recording a script, VuGen lets you medify the settings in the RECORDING OPTIONS. To open the recording options, choose TOOLS —+ RECORDING OPTIONS or press CrRL+F7, Select the General: Script node. Make sure to check this setting CLOSE ALL AUT PROCESSES WHEN RECORDING STOPS. This setting allows VuGen to automatically close the application under test (AUT) processes when VuGen stops recording, (disabled by default) Recording Options - Seript 25 2-6 na Petes Recording for the Web rae GP cnmratsfenstirctye ster manson 3 Conn LL Desc ena ik ne goat han tal Teste ik eri ty ae sec reser) [om] tue |e Figure 2-5 Think Time Setting Use a threshold value for think time. Ifthe recorded think time is less than the threshold, ‘VuGen does not generate a think time statement, You also specify the threshold value, ‘The default values is 3 - if the think time is less than 3 seconds, VuGen does not generate think time statements. If you disable chis option, VuGen will not generate any think times. (enabled by default) Set this option according to the user you want to emulate, Users interact with the application according to their experience level and objectives. More technically proficient users may work very quickly, while new users and those involved in certain kinds of business processes may proceed very slowly. By estimating these navigation times, virtual users can be made to emulate their real-world counterparts more accurately during a load test. If you are unsure of these times for various user types, ask application experts or those knowledgeable about your business processes. Recording Options - Think Time Recording for the Web Figure 2-6 Recording Level - HTML vs. URL Recording Levels Selecting a recording level in VuGen lets you specify the information to be recorded and which functions to use when generating the seript. The available modes are: a) HTML-based seript b) URL ased script HTML or URL recording is one of the more important choices a script writer must make. The difference lies in the layer at which the user steps are recorded. Each has its, advantages. For LoadRunner scripts, HTML level is a common choice, On very complex web applications, the entire script may need to be recorded at URL level. HTML is a higher level that records in "Browser" or "Context Sensitive" mode. This setting allows the Browser to determine which page resources (such as images or Flash content) should be downloaded depending on the HTML source that was downloaded during replay. URL is a lower level that records in “Analog” mode. This setting does not allow the browser to determine which page resources (such as images or flash) should be downloaded. Each resource is recorded in the script during the Recording session. This level will also record any hidden items, such as session ID information, sent to and from the server. Recording Options - Recording Levels 27 2-8 Recording for the Web FTE aecen rte Figure 2-7 HTML and URL Differences These code examples, generated from Mercury Tours, underline the differences. When data is posted to a server by the browser, the two modes generate two different statements in the script. * HTML level will generate a web_submit_form statement that only records options that an end user is allowed to see and change. If a problem is encountered with a form submission in HTML mode, you can enable the URL option under HTML, Advanced to instruct VuGen to record all of the requests and resources from the server. URL Level will generate a web_submit_data statement that records all data that was actually sent from the browser to the server. Note that the URL mode includes hidden information that the HTML recording does not pick up. Quite often, this will include session ID information. These two scripts represent the same Business Process. The difference between the scripts is the Recording Level used to generate the script. ‘The script on the left was recorded in HTML mode. Notice that the HTML mode contains far fewer steps. Only cookies, URL requests, a Submit Data, think time and a link were added to this script HTML and URL. Script Differences Recording for the Web Contrast that to the script on the right, recorded in URL mode. This se! more additional steps than the HTML mode script, Each item requested during this recording is represented as its own step in this recording. HTML and URL Script Differences 29 Recording for the Web Begin Recording User Steps 2410 [ew carne es OS Bek tw Pat Wer Hue nk arn oh 1B Fe satmead ew Osh PLR) ee ae [aiefeoorar wacnmmy] - tien Introduction to Recordin _ teeny + - 2. Flin the relevant trove | Before You Start information for recording About Recording eesenne Teecn Sectng | Bapentumad, Pires aj es 8008 spect ernie a ce Ceci © mates a tx | mee Bo Se) 8] cere __ ier ra a Figure 2-8 Specifying the Recording Det: After the Recording Options have been configured, the new script can begin recording User Actions. Follow the steps below to begin recording: 1, Select Vuser — START RECORDING, or click the START RECORD bution on the RECORDING APPLICATION task info panel. The START RECORDING dialog box opens. In the START RECORDING box, enter the details for application type, program to record with, and the URL of the application to test, Note: Take note of the RECORD INTO ACTION field. VuGen supports the ability to record into multiple action files, ACTIONS provide a more programatie approach to scripting that assists with other Mercury products that utilize VuGen. Think of action files as a way to split up portions of your script into smaller sections so you can selectively replay portions of the script. We will talk more about Actions in the Actions and Transactions. chapter. For our purposes right now, use the default values. Begin Recording User Steps Recording for the Web Perform User Steps for Recording OD A] Gime irae Gur GIS SADR Pecans RHR =n 30113, 2005, Aegatres user con sigan User Nn fa ‘Ths island is surrounded by coral reefs, Password Ss guratee seh ns sad “with beautiful beaches. Luxury resorts have > Taken up residence along mo! ofthe [oentnatansT I Figure 2-9 Perform User Steps in the Browser 1, Once the details are entered in the START RECORDING dialog box, click OK. VuGen starts your application and the RECORDING toolbar appears. 2. Wait for the browser to appear and for the application to finish loading before continuing. The RECORDING toolbar should appear floating above the browser. Do NOT close the browser - this will stop the recording, 3. Perform the user actions for the business process you selected for recording. Perform User Steps for Recording 241 Recording for the Web 2412 Ania, ‘swe | ReasreR | ourronr ] contact ‘Welcme back Mercy Tour! Ero yoy oe iation 9 ase he oy aso Hye ot ra Posse Figure 2-10 Stop Recording During recording, you will notice that the recording icon continues to blink as you go through the user actions. Click the Stop button when all the steps have been recorded. Make sure to save the script after you have stopped recording. It’s a good idea to save your script more than once, each time with a different name, When you modify a script and replay that script, VuGen will automatically save the script before replay. If your modifications did not work, you will have lost your original script if you did not save an original copy and a working copy of the script. To save a script: Select FILE SAVE AS, or click the SAVE bution ff to save the script. Specify a meaningful file name and location in the SAVE TEST dialog box, then click SAVE. ‘Stop Recording Recording for the Web Recording Summary radatan The gh pane shows Guana mapihe ye recon, “ls sapshts en wry tet eee business procs ws comments eared cegtmammsmengnet] Witwne tot recarded pope, ck Recird Ana to roves he business Figure 2-11 Recording Summary Displays Information Once the recording is completed, the workflow moves to the Recording Summary step. ‘This step provides a summary of the recording, including the protocol information and the actions into which the session was recorded. This step also provides thumbnails of the recorded snapshots. Recording Summary 243 Recording for the Web Working with Thumbnails 214 Protocols.» lens rc es ed eit rg er ose ced saocaremarses | Figure 2-12 Recorded Thumbnails ‘Thumbnails display the snapshot in HTML as they would appear in a browser, making it easier to select the correct step. Th nbnails can be viewed in Workflow Wizard, or through TREE VIEW. VuGen lets you rename thumbnails for easier identification, annotate them to describe what actions the step performs, and viewing them in a larger size. Note: After you insert an annotation for a thumbnail, VuGen places a red mark at the bottom right corner of the thumbnail to indicate that an annotation exists, If you move your mouse over the thumbnail, VuGen shows a popup of the annotation Working with Thumbnails Recording for the Web Be EE Yaw emt ter ore Tock don Hes Jt] - |! esatead + mo) vile M9 ipa) Bfoelys Es = aT] Se Te soon [rami] Gatien Soren | ein renee mente wenden 9S pipe Sra saccing etmien ca | 2 secur aockaen += Bij Suamiram cen cates Sy Soman cn Ge core 2 Repley + | Wercury ad | Lae Aiie jem | = Teepe Figure 2-13 Tree View Now the script is ready for further enhancement and editing. You can do so in Workflow Wizard view, TREE View. or in Scripr View, Workflow Wizard view is step-based (as discussed in the Intro chapter), TREE View is icon-based, and SCRIPT VIEW is. text-based, The Tree View displays the recorded user actions in step format, Each icon represents a step of the script, We will talk more about Scrip View in the Intro 10 Script View chapter. Viewing The Finished Script in Tree View 2-15 Recording for the Web Tree View Icons 2-16 2 arremoer Femme ot ‘Soest Figure 2-14 Tree View Icons and What they Signify ‘The following are a selection of common web icons found in a completed script when viewed in TREE VIEW URL: A URL icon is added to the script when you type in a URL or use a bookmark to access a specific web page. Each URL icon rearesents a web_url function in the script ‘The default label of a URL icon is the last part of the URL of the target page. Link: A link icon is added to the script when you click a hypertext link while recording. Each link icon represents a web_link function in the script, The default label of the icon is the text string of the hypertext link. Image: An image icon is added to the seript when you click a hyperlink attached to an image while recording. Each image icon represents a web_image function in the script. If the image in the HTML code has an ALT attribute, then this attribute is used as the default label of the icon. If the image in the HTML code does not have an ALT attribute, then the last part of the SRC uttribute is used as the icon’s label. Form/Data Submission: A Submit Form or Submit Data icon is added to the script when you submit a form while recording. Each icon represents either a ‘web_submit_form function or a web_submit_data function in the script. The default label of the icon is the name of the executable program used to process the form. Tres View Icons, Recording for the Web Understanding Recording Snapshots Figure 2-15 Recording Snapshots Displays the snapshot in HTML as it would appear in a browser. This bution is available for both the Recording and Replay snapshots. Use this view t make sure you are viewing the correct snapshot, Server Response: Displays the server response HTML code of the snapshot. This button is available for both recorded and replayed snapshots. The HTML view also shows a tree hierarchy of the script in the left pane, with a breakdown of the document's components: Header and Body with the title, links, forms, ete. Client Request: Displays the client request HTML code of the snapshot, This bution is available for both the recorded and replayed snapshots. The HTML view also shows tree hierarchy of the script in the left pane, with a breakdown of the document's components: Header and Body and their subcomponents, Replay snapshots will be explored in the replay chapter. Understanding Recording Snapshots 2417 Recording for the Web Renaming Steps in Tree View 2 alata GR Mew Pot Yaw die De ni to cleg-/) fe sett ee OID we Ge AIGSS sur [Battag menneon worm] = Tee x) T [mein | Gethoges | vw Ree Recent Ssatet Jf sara connec none eot 1 Sant Fom en recep save oars BE ston con nocanason Rcd? Bini ret sedate Bi ee TT Se sured, Double-click the step ety : totsten | Be arr oo - paontmae ITE} hana 218 Figure 2-16 Renaming Steps Why rename a step? Because recorded step names are not intuitive. When working with a large script, it will be difficult to find the right step quickly for debugging or to add enhancements. Iv is a good practice to rename the recorded steps to a more intuitive name, Double-click the step in TREE VIEW and the STEP PROPERTIES dialog box opens, Overwrite the name in the STEP NAME edit box. Renaming Steps in Tree View Recording for the Web Returning to the Workflow Wizard Gk Yew Wet wpm anne Tak ree Ewe Gilet! femmes sa Gly 31 ial [ata [onto eS OTP ATRT ww xT tae = [orten | Goan | arerRomee a > het tec Soe . §Qtewtsremnsenerrenntarrtinnt eeecnaeg [B)SteFonrconnesocasmreiermocrselt sae | cepmrefarend + ‘Ts tsi + tostntn Sogo toon soit | Comer Teepe _ _ [licking on this bution takes you back || [Famosos | to Workflow View. Figure 2-17 Returning to the Workflow Wizard View You can switch back to the WORKFLOW wizaRD view at any time, by clicking the RETURN TO WORKFLOW bution on the TASKS list pane. This takes to the step that is currently highlighted in the TASKS list. Returning to the Workflow Wizard 249 Recording for the Web Saving Scripts oy Fold web_proect Seng Files related tothe script Figure 2-18 Script Folders and Files A working script directory should be established on your local working machine. This directory will be used to save scripts created with VuGen, It is recommended that the directory be located in an easy to find location, usually off a drive root as shown above, ‘Once the script is saved, you will sec the folders and files shown above. Save your script name without spaces. In the example shown above, web_project is the folder. Under that is the folder that contains the script named hab2Seripei. Under tab2seript are all of the files related to this script. When the script is saved initially you will see the folders shown above. In the Replay lesson, we will leam what other folders are created when the script is played back. 2-20 Saving Scripts Recording for the Web Summary Summary Record web scripts based on planning by — Setting RECORDING OPTIONS + Protocols + Recording Identify when to use HTML and URL recording levels based on scalability and ease of use — InHTML mode, VuGen records web suemic form — In URL mode, VuGen records web_submit_e: Workflow wizard guides through scripting building tas s Annotating thumbnails allows for easier understandings of the special requirements for that step and easily identify the step. 2-21 Recording for the Web Exercises Objective: In this exercise you will use VuGen to record a script that signs in to the train site Mercury Tours and reserves a seat on a flight. Setup (Do not record this) 1. Set Internet Explorer to always check for a new page. a) Open the browser, b) Select TOOLS > Orrio GENERAL tab. or TOOLS > INTERNET OPTIONS) and go to the ©) Under TEMPORARY INTERNET FILES section click the SETTINGS button. d) Select EVERY VISIT TO THE PAGE, then click OK to close all dialogs. ©) Close the browser. Invoke the Virtual User Generator (VuGen). a) START > PROGRAMS — MERCURY LOADRUNNER APPLICATIONS > VIRTUAL USER GENERATOR. bd) Wait for VuGen to open. 3. Create anew script. EF a) Click ScRipTs tab. b) On the START PAGE under SCRIPTS tab, click the NEW VUSER SCRIPT button, or select FILE —> NEW from the VuGen menu, The NEW VIRTUAL USER dialog box opens ¢) Select NEW SINGLE PROTOCOL SCRIPT and from the AVAILABLE PROTOCOLS list select Wes (HTTP/HTML). and click OK. 4) This opens the script in a new tab and Introduction to Script Creation page gets displayed. Part 1: Record Sign-In 1, Click the NEXT button at the bottom left under the task list to move to the RECORD APPLICATION task. 2-22 Exercises, 2. Exercises Recording for the Web Set options to make sure that the VuGen closes the Application under test and the Recording Level is HTML. a) b) °) d Click the OPEN RECORDING OPTIONS link under the RECORDING OPTIONS section or select TOOLS + RECORDING OPTIONS to open the dialog box. In the GENERAL: SCRIPT node, select CLOSE ALL AUT PROCESSES WIEN RECORDING STOPS. In the INTERNET PROTOCOL: RECORDING node, HTML-BASED SCRIPT should be selected as the Recording Level Click OK to close the dialog, Start Recording. a) Dy °) d e) Click the Nex or START RECORDING button. The START RECORDING dialog opens. In the Program to Record box, make sure "Microsoft Internet Explorer” is selected or choose from the drop list If the following URL is not already present in the URL box, then type it in: ntep: //localhost /servlets/can,mercurytours, serviet Nelconegervies In the Record into Action field, make sure it shows "Action" or choose from the drop list, Leave RECORD THE APPLICATION STARTUP checked, and click OK. Was Mercury Tours application invoked successfully by VuGen? Why is it necessary for VuGen to invoke the browser? In the browser, sign in to Mercury Tours as" a) Type Jojo in the USER NAME field. 2-23 Recording for the Web b) Type bean in the PassworD field, ©) Click the $1GN-IN button. The FLIGHT FINDER page appears. 5. Record the user steps for purchasing a ticket, a) _ Inthe browser, enter the flight details to search for available flights. Accept the defaults forall fields on the FLIGHT FINDER page except those shown in the table below. Arriving In b) Click CONTINUE. ©) Inthe browser, accept the default flights for both directions of the round trip, By default, the first available flight is already selected for each direction when the SELECT FLIGHT page appears. @) Click the CONTINUE bution. ¢) In the browser, type in the required passenger and credit card information. On the BOOK A FLIGHT page, fields which require data entry have red labels, Enter the passenger name and credit card number. Use data from this table, FIELD | VALUE First Name | Joseph Last Name | Williams Number 987654321 f) Click SECURE PURCHASE. Ney Was the Fish Confirmation page received from the web server? 2-24 Exercises Recording for the Web 6. End the business process by signing off from the web site, In the browser, click the SIGN-OFF bution located near the top of the page and do not click the log-off button, 7. Stop recording. a) Click the Stop button ML in the floating Record toolbar Note: You should create the ¢:\rvaining\vaGen8. 1ScriptingForweb\scripts directory hierarchy on your computer workstation if it doesn’t already exist. The training will refer to this tree when saving ané opening lab exercises. This directory also has the solution scripts in the \solutions folder. 8. Wait for the RECORDING SUMMARY to appear. 9. Save the seript as e:\Training\v ng. 1ScriptingForileb\Scripts \Recording ) From the VuGen menu bar, select FILE + SAVE AS, or click the SAV. toolbar button, ual b) The SAVE VIRTUAL USER window appears. ©) Browse to the directory \Training\WuGend .1scriptingPortieb\Seripts. d) In the FILE NAME field, enter Recoraing ©) Click SAVE. wv What information does the Recording Summary provide for recently recorded script? ww In VuGen, what is it that indicates that the sign-in was recorded? Look for visual clue. Note: Look in the recorded thumbnail. Exercises 2-25 Recording for the Web 2-26 Exercises: Replay Objectives After completing this chapter, you will be able to: * Identify and configure the appropriate web run-time settings for replay. Run the script in VuGen to verify script functionality. © Recognize the debugging tools. 34 Script Workflow Figure 3-1 Script Workflow After recording, always play back the script to verify that the script is running as intended. In this lesson, we will learnt about the settings we need to set in order to verity the script’s functionality, and we will see how the different RUN-TIME SETTINGS affect the playback of the script In VuGen you record, enhance and debug the script, You incorporate the s of a scenario to load test your application under test pt as a part 32 Script Workflow Replay Debug Scripts By Running in VuGen * The goal is to perform a “sanity check” before the script is ass Controller ned in the © Test the script with just one iteration to verify basic functionality. * Configure RUN-TIME SETTINGS to test specific aspects of the script. It is strongly recommended that you re-run the script after any modifications or enhancement to verify the integrity of the script. Icis very important to understand that when the script is run from VuGen, you are running the script for debugging purposes on y. In the other lessons of this course we will leam how to enhance the script to address issues with the script, Itis very important that after each enhancement, you play back the script to make sure that there are no errors generated. Also, after each enhiancement, choose FILE > SAVE AS. This will allow you to keep a buckup of previous versions of the script. This comes in handy when the recently enhanced script does not work as expected. Debug Scripts By Running in VuGen 3-3 Replay What are Script Run-time Settings? Script Run-time Settings * Defines settings that affect script execution like run-logic, pacing, logging and think time * Script run-time settings allow you define ‘tow a script behaves without having to edit the script * In VuGen, these settings are used for debugging purposes and to solve playback problems, 34 What are Script Run-time Settings? Replay Run-time Settings eR Yow Peat Watt tn kit Lgtip li fommned sng ii 5 Jaitas omnes WOT] a won Introduction to Verification etary AbCUE Replay | = AaNAREESESS . sma recete Soames ore oy : 4 tite : = 2 tacoma vie =! Pace = tegwetorsos = Before Replay | mara Sertnoy ec ws Figure 3-2. Run-time Settings Av: lable for Web Script After recording a script, you need to set the RUN-TIME SETTINGS. These settings let you control the behavior of the Vuser when running the script for debugging purposes. Options under the General Node are avail SETTINGS are specific only to the web. ble across all protocols, the other RUN-TIME Do we need to configure all RUN-TIME SETTINGS available for the web protocol for debugging a script? Let us look at these settings to see which we need for debugging purposes, Run-time Settings 3-5 3-6 | ous 3 men ae | "sae \\ Te = | iene ‘Spots rane cin orpet be Viera Replay Figure 3-3 Run-time Settings Needed for Basic Script Replay These settings are what we are cor other settings as and when we need. cerned for the basie script replay. We will look at the Run-time Settings For Basic Script Replay Run-time Settings - Run Logic = i | tatae “Action omatutes | | ier” | gone | eg — ‘Spanish muertos eee tert Figure 3-4 Run Logic Setting Set the iteration to one for now Replay Run Logie defines how to set iterations. In the Actions lesson you will learn more about what steps to iterate, For now, itis important to understand that you should run the ‘pt with just one iteration to confirm script functionality, Later we will see when to run a script with multiple iterations. Set the script to run with one iteration at all times. By default the iteration value is set to Run-time Settings - Run Logic Replay Run-time Settings - Log ste | tos Meg eigg, “raf [BS Semmens zi | sae © shar donne | Networ Logmessenes alihe detel level | T Pewwaer bsintion i eee, eeawterndb ee | Peencee F gesekennaby camer Domina be PF bsvencedce | Coren hese Sendo Log——— —. ‘Sends a steel ncton nd massagos sending sig ououten tole The eubet epere on he Veh Genera Ge Range nto AS unodats |] ewe | tee | | | igure 3 5 Log Settings (Default settings shown) During playback, scripts log information about themselves and their communication with the server. These messages can be captured in the REPLAY LOG by checking {enabling) the Extended Log before playing back the script. This information is helpful in finding the cause of problems if an error occurs during playback. We will discuss the other settings in the coming lessons. 38 Run-time Settings - Log Replay Run-time Settings - Proxy sre © mioeraeananrtatbone aa nomena | "soa | Boner & Noam et comet ble!) | ray tin rc | ovens Fae | | Hose | Fara. mae be crscnt tr ec ht ey oe i | Figure 3-6 Proxy Setting What is a proxy? A proxy server acts as an intermediary between a workstation and the Internet so that the enterprise can ensure security, administrative control and caching. It is important to use the same proxy settings during playback that you used during recording (if any were used.) VuGen will act as the browser and send all of the requests directly to the server. If the replay of the script is on the same machine where the script was recorded use this option: "Obtain the proxy settings from default browser.” IF replay is on a different machine, or if you need to change proxy depending upon which application to run the script against, then use this option: "Use custom proxy.” un-time Seitings - Proxy 39 Replay B zs ain Gh GR Yew set ver aes [Te | rdw tb je BO titted » |G troamscnncmen. |Gee kt GSS a gar yc ee [Basta Jroomens wes onto 4 ears say Introd. | About F | stom . renstene alan ese |e tater Stahmcemmts = RUN-Ti Stns ian Patong eo BR | | | ig | memeeroaes + eons we | nee F tiyentseciesn hese | Greene | sea : | Penance dy | Feat se fat — ows sant ton oem a] ge) oe zenenaion Pel [Endre Dy] Ci Figure 3-7 General Options Setting After you record a script and set the run-time settings, you test the seript by running it You can also set General Options that allow you to set the recording and replay options. These settings are global, meaning you have to set them only once per VuGen install To access the General Options dialog, select TOOLS —> GENERAL OPTIONS. 3-10 ‘Also Set General Options Replay General Options - Replay Emin: “TPoransteizaer Peclay | Envternentl Dakar | pews LS : | On animate functions in Action sections bent Dctay F Baie Figure 3-8 Replay Tab Animated run delay: Allows you to toggle between running a script in animated and non-animated modes. When you run in animated mode, VuGen highlights the line of the soript being executed at the current time, Use this made when you are running the script afier an error has been detected, in order to easily find the step with the error, When you run in non-animated mode, VuGen executes the script, but does not indicate the line being executed. Use this mode when all of the errors have been fixed. Prompt for results directory: Prompts you for a results directory before running a seript from VuGen. If this option is not selected, VuGen automatically names the directory result]. Subsequent script executions will automatically overwrite prev ones unless you specify a different result file, Note that results are always stored in a subdirectory of the script. After replay show: Instructs VuGen how to proceed after the replay. Selecting the Visual Test Results option opens the TEST RESULTS SUMMARY (This is the same as choosing View —> TEST RESULTS.) This setting allows you to open the TEST RESULTS automatically once script replay is completed, General Options - Replay 311 Replay General Options - Environment > Auto show function syntax F Auto complete word it pt. Courier ~~ _Seleet Font Figure 3-9 Environment Tab Auto show function syntax: When you type the opening parenthesis of a function, VuGen shows the syntax of the function with its arguments and prototypes. To enable the showing of the syntax globally, select the check box adjacent to this option, To disable this feature, clear check box. If you disable Show Function Syntax globally, you can still bring up the syntax by pressing ctr1+snifz+Space or choosing Epir > SHOW FUNCTION SYNTAX fier typing the opening parenthesis in the editor. Auto complete word: When you type the first underscore of a function, VuGen opens a list of functions allowing you to choose the function without having to manually type in. To enable word completion globally, select the box adjacent to this option, To disable this feature, clear the box. If you disable this option globally, you can still bring up the function list box by pressing cex1+Space or c10osing EDIT > COMPLETE WORD. 342 General Options - Environment Replay General Options - Display | igo aga Auto arrange window Test eite F Generate repot dung sorint execution DET Figure 3-10 Display lows you to specify whether VuGen displays the run-time viewer, whether VuGen generates a report during script execution, and other such display choices. These tools will help in debugging the script. If the Show browser... during replay option is checked you will be able to see the Run-Time Viewer. Select the "Auto arrange window” check box to minimize the run-time viewer when script execution is complete, ‘Time Viewer is NOT a browser, so if the pages do not render properly in the me Viewer, it does not necessarily mean that there is a problem. General Options - Display 3413 Running the Script eri eS oacteoe » 8H Ol alle a iia] Bane tne |S ‘andor Heo Replay slat 285 Batiag Jratomanctow we neces Puontashne 2Resiey Foe mah Introduction to Verification About Replay Run-Time Settings Before Replay | | | conten Pp 3k the Start Replay button | 2 ey to playback the script | I | 3-14 Figure 3-11 Playing Back the Script Click the START REPLAY bution to play back the script, Based on the option selected in the General Options, you will be prompted to enter a Results directory name, It is a good practice to save the results of each run in order to isolate and debug errors faster. When the script execution is complete, communications between the script and the server are listed in the REPLAY LOG, The word “Error” be displayed in red. * or “ERROR” ona line will cause the line to It is also a good practice to play back the script after each code change. This will ensure that the script works as intended, Running the Script Replay Run-Time Viewer ‘SELECT FLIGHT ___ Ea ‘Select your departure angetun fight fom te selections Below, Your otal pce wl be higher than uated you elect oy ona diferent ate for bot lees of your Acapulco to Zurich 97252005 ee a TT q__ Blue Skies Aine 190 508 nonstop ken: $706 (baad un ou ep) Phy Blue Skies Airtines 194 7108 non-etap rice: $723 (based on round ip) Figure 3-12 Run-Time Viewer When you run a web script, the web servers accessed by the script download information. This information is usually in HTML format. The script saves this information to the scripts results directory. Each web page is saved in HTML format as a separate nti file, While the script runs, the run-time viewer loads the .nem files that are saved in the script results directory, and displays the resulting web pages. Run-Time Viewer 315 Replay Replay Summary is Ge Yew Bow wae ne Toe ec eb soi wits 2 Gee) Dom yee (SITES ig ar {iste Je Tomoncetes= We OPA weed Last Replay Summary L.necerdng —* esl rectory: vest ‘wating atte: NO errors detected zaesay + dats by sanguine ep deer + eter Snopsheters be tae bane eden Verification amvepareforioad = Yous oe fee ifort asin To iew er mod e sere, uta 2 ery Agni] _ ta Onin Figure 3-13 Replay Summary The replay summary displays a rundown of the results of the script execution, 346 Replay Summary Replay Per SHORE a | ~ | bem = 4 Figure 3-14 Test Results Window After you run a script, you can view a summary of the test results using VuGen’s TEST RESULTS utility. The Test Results utility shows the overall results and detailed level report on each step. the Test RESULTS click on the VISUAL TEST RESULTS link on the REPLAY st RESULTS. To acces SUMMARY page or open VIEW > Test Results Window 317 Replay Replay Log nn Verifications ‘The replay lo ists al th messages Eecing wae cence the srit has stopped running Figure 3-15 Replay Log ‘The Output window's REPLAY LOG displays messages that describe the actions of the script as it runs, This information tells you how the script will ran. When script execution is complete, you examine the mes whether your script ran without errors. ages in the REPLAY LOG to see Various colors of text are used in the Replay Log: = Black: Standard ouput messages = Red: Standard error messages — Green: Literal strings that appear between quotation marks (e.g. URLs) Blue: Transaction Information (starting, ending, status and duration) Orange: The beginning and ending of iterations If you double-click on a line beginning with tke Action name, the cursor jumps to the step within the script that generated that message. 318 Replay Log Replay Debugging Tools © Run-Time Viewer: The run-time viewer shows each web page as it is accessed by the script. This is useful for debugging, as it allows you to check whether a script has accessed the correct web page of not. © Replay Summary: When the script execution is complete, displays the summary of the script status. © Test Results window: Summarizes the success or failure of each step of the playback web script. -ommunications between the “or” or “ERROR” © Replay Log: When the script execution is complete, script and the server are listed in the REPAY LOG. The word “ on a line will cause the line to be displayed in red, * Snapshot Results window — Page View = Server Response = Client Request Debugging Tools 3419 3-20 Replay Figure 3-16 Test Result Directory In the example shown above, ve_pro ject is the top folder. Under that is the folder that contains the script named Lab2Script!. Under Lab2Script! are all of the files related to this script. The result folder holds the test results summary. When the script is, replayed, you will see the folders shown above. Based on the settings that you choose in the GENERAL OpTions Replay tab VuGen automatically names the directory result!, result2 and so on, If the option is not selected subsequent script executions will automatically overwrite previous ones unless you specify a different result file, Note that results are stored in a subdirectory of the script. What are the next steps? Now that the script works as expected, it can te included as part of a load test scenario or further enhanced to satisfy load testing goals. Where are the Test Results Saved? Summary Summary Configure Run-time settings for web debugging: = Run Logic Play back the script and verify functionality using: — Replay Summary — Test Results window = Replay Log — Snapshot Results window — Run-Time Viewer Replay 3-21 Replay Exercises 3-22 Objective: In this exercise, you will play back the script recorded in lesson 2 - Recording. Part 1: Replay the Script 1, Open Recording and save it as Playback. If you were not successful in creating Recording script you can access the solution script from ¢:\Teaining\VuGen8 . 1Seript ingForkteb\Solutions\ Recording. 2, If you are in the WorKFLOW VIEW then go to the TREE VIEW. a) View > TREE VIEW or click the TREE VIEW icon, [Te In VuGen, rename the submit Form: com.me SignonServlet step {0 FindFLight. rytours servlet a) Select the “SUBMIT FORME . . . SIGNON.SERVLET” tree icon, and right-click the SIGNON.SERVLET icon, and select “PROPERTIES” from the pop-up menu. ‘The SUBMIT FORM STEP PROPERTIES dialog box opens. b) Click the GENERAL tab. ¢) Overwrite the entire contents of the STEP NAME box with Pind Licht d) Click OK. 4, Rename the other Submit Form steps according to the Following table, RECORDED NAME, EW NAME ‘Submit Form: com.mercurytours.servieLReservationServlet_ | Select F1igh Submit Form: com.mercurytours.serviet.PurchaseServiet_ | BookeLight fight Submit Form: com.mercurytours.serviet.PurchaseServlet2 Set the General Options, a) Select TOOLS > GENERAL OPTIONS to open the GENERAL OPTIONS dialog box. b) Inthe REPLAY tab, check PROMPT FOR RESULTS DIRECTORY. ¢) Select VISUAL TEST RESULTS in the AFTER REPLAY SHOW list box. Exercises Replay Exercises 6. 4) Click OK to close the dialog box. Return to WORKFLOW VIEW. a) Click on RETURN TO WORKFLOW button at the bottom left under the Task pane. Notes If you do not see the list of tasks on your left side then make sure that the TASKS button on the VuGen menu is selected. 1. i. Go to VERIFY REPLAY step. a) Click the NEXT button at the bottom left. This will move to VERIFY REPLAY task step if you were on RECORDING SUMMARY step or just click on the VERIFY REPLAY task on the Task pane. Set the RUN-TIME SETTING a) Click OPEN RUN-TIME SETTINGS link on VERIFY REPLAY step or select VUSER — RUN-TIME SETTINGS from the menu. This opens the RUN-TIME SETTINGS window. b) Make sure that the settings agree with those in the following table. Do not change other settings that are not in the table, NODE SETTINGS Run Logie NUMBER OF ITERATIONS - 1, Select STANDARD LOG. ©) Click OK to save the changes. Run the script Playback. a) Make sure playback script is open in VuGen, ») Ifyou are on VERIFY REPLAY step then click on the START REPLAY bution or select VUSER — RUN or press the RUN button on the VuGen toolbar. Accept the default results directory. a) The SELECT RESULTS DIRECTORY dialog box opens, b) Accept the default name resuie1 and click OK. Review the REPLAY SUMMARY. 3-23 Replay In the Replay Summary, what indicates whether the script run passed or failed? .. Review the Iteration | Summary in the Test RESULTS window. a) Click the ITERATION L icon. . Display the Flight Confirmation page that VuGen captured during playback, a) Inthe Test RESULTS window, click the “+ Test Results icon tree. sign to expand FTERATION 1 in the b) Click the step SuBMrr FoRM: CONFIRMFLIGHT, Note: You can also expand all steps beneath a selected step by selecting Virw EXPAND ALL. or by pressing the asterisk key [#] on the numeric keypad. ww 14. 3-24 Was an image of the Flight Confirmation page captured by the Test Results? Review the REPLAY LOG at the bottom of the VuGen window. a) Click the SHow/Hipe Output wixvow Replay Log. icon, This will open the What is the purpose of the REPLAY LOG? Close the TEST RESULTS window. a) Click the close icon [) at the upper right comer of the title bar, or select FILE — EXrr from the Test RESULTS menu. Close playback. Select FILE > CLOSE. Exercises Replay Challenge Exercise: 1. Replay the Recording seript with different log options in the RUN-TIME SETTINGS. Note down your findings. 3. You will use more RUN-TIME SETTINGS options in the coming lessons. Exercises 3-25 3-26 Replay Exercises Transactions Transactions Objectives After completing this chapter, you will be able to: © Explain the function of a Transaction in « recorded script '* Insert Transactions to measure busi 88 process response time. a4 Transactions Script Workflow Enhance b Enhance Web Script =Parameters + Corelation + Verification Figure 4-1 Script Workflow The script so far has been recorded, played back and debugged. Now the script is ready for enhancements. The first step to enhancing a script is adding Transactions. Script Workflow 4-2 Transactions What Do Transactions Measure? Request (Transaction starts) Sign-in we Transaction ae Response took 8 sec. User (Transaction ends) Web Server Transactions measure the transmission and response time between client and server. Figure 4-2 Transactions “Transactions measure the interval between the time a request is sent to the application and the time the server response is received by the user. About Transactions: LoadRunner’s means of measuring elapsed response time of one or more user steps Definition of Transactions should be part of the planning process Implemented by adding Start Transaction and End Transaction steps * May overlap and may be nested * May be added during or after recording What Do Transactions Measure? 43 Transactions Why Add Transactions? 44 Transactions help: To measure mission-critical, heavy throughput and dynamic content business processes. In determining the nature of Application problems. For example, if the transaction is slow right now, it would indicate a temporary problem, but if itis slow over a period of time, this could will signify that system load is growing and performance is degrading. In estimating which business process is failing by tracing the failed transactions. With reporting the failed business process to Analysis graphs. Why Add Transactions? Transactions The Start and End Transaction Icons deen anm t | [ois ere [renee “aej sal J Fr eo ines Fas De Figure 4-3 Transactions Icons To measure a business process or step, insert start and end icons to mark the beginning and the end of the transaction you are measuring. Within a script, you can mark an unlimited number of Transactions, each with a different name, During load testing, the Controller measures the time that it takes to perform each Transaction, These timings are then reported to Analysis graphs, Transactions can be added during or after recording. Both methods are discussed in this lesson. ‘The Start and End Transaction Icons 45 Transactions Use the Workflow View to Add Transactions After Recording 46 Make sure you are on the Transaction step in the Task pane. Identify the first step to be measured in the thumbnail area. Click the New Transaction button, Select the first step to add the Start Transaction icon. Select the last step to add the End Transaction icon. Specify a name for the new transaction, Use the Workflow View to Add Transactions After Recording Transactions 1. Make Sure you are on the Transaction Step in the Task Pane naecedeg Tarai Bh = coe cns ‘Make sure you are | on Transactions step | i a Soe Figure 4-4 Transaction Step in the Task Pane VuGen uses the Transaction Editor to allow you to add and manage transactions directly from a thumbnail view of the script. 1. Click TRANSACTIONS in the ‘Task list to open the Transaction Editor. Note: To exit a transaction during the above sequence, press the Esc key. 1, Make Sure you are on the Transaction Step in the Task Pane 47 Transactions 2. Identify the First Step to be Measured in the Thumbnail Area Load Testing Goal: Measure the Sign-in response time This step will give time elapsed for sign-in step. Figure 4-5 Select the Thumbnail 2. Inthe thumbnail area (middle pane), scroll down to the steps that you want to mark as aa transaction, Select the thumbnail that will satisfy your load testing goal. ‘o see more thumbnails per page, click the toolbar’s TASKS button to hide the 48 2, Identify the First Step to be Measured in the Thumbnail Area Oeetemad » a! allo WD [abel) see free |S Fag [Petre wou TATA] a epi fortoad + ae Figure 4-6 Click New Transaction Button Transactions 3. Click NEW TRANSACTION button in the right pane. VuGen shows instructions in the status area above the thumbnails. 3. Click the New Transaction Button 4-9 Transactions 4. Select the First Step to add the Start Transaction Icon 0 Aya aa Sea saya Paros Peet i = | ot | tr “ae | oe 4 faite pea Figure 4-7 Select the Beginning of the Transaction Note: The cursor will form a hand with the start transaction icon image attached. 4. Place the cursor at the starting point of the transaction. 4-10 4. Select the First Step to add the Start Transaction leon Transactions 5. Select the Last Step to Add the End Transaction Icon | = SCD Det eee an tse Are a Min | tla i erie een S) elo Gel See wm GTS ieee Sather] oeonaTon wT ATRT 7a E CS Ty | eco feosrasuanes Taha a= Figure 4-8 Select the End of the Transaction Note: The cursor now will have the end transaction image. 5. Now select the end of the transaction, 5, Select the Last Step to Add the End Transaction Icon 411 Transactions 6. Specify a Name for the New Transaction Se ee Le Be beet Wear dew Lede ein ae Jeo id esned sa Ol olls Ue fos) Bee wre GEST ises [stan Jretoransten- woh OTTPATRT] ro: on A] Norton ;nsaction name here —— en [Fa a Nereis 4 srcseeFortond + eee ES igure 4-9 Provide a Meaningful Name Note: VuGen will now provide an edit box above the thumbnail where you recently added the transaction, 6, Type in a transaction name in the edit box. If you have selected multiple thumbnails, then type the name in the bracket directly above the transaction's first step. To compiete the transaction, press the Enter key. 412 6. Specify a Name for the New Transaction Transactions Transaction Editor a in| stant at Oo ole 2) PY Swe the — “Transactions Figure 4-10 Transaction List Once you have added the transactions, The transaction editor allows you to: * See all the available transactions for the script in the wansaction list located on the right pane of the Transaction editor. You ean view a complete list of the transactions in the script, or only those in a specific action. * — Rename, Delete and Sort under the Transaction Name pane. © Change the starting point of a transaction, by dragging the transaction opening, bracket to a new location. And dragging the transaction closing bracket to a new location to change the end point. Transaction Editor 4-13 Transactions Add Transactions During Recording 444 Click the START TRANSACTION toolbar button, ‘Type a transaction name and click OK. Complete the user actions for the process to be measured. Click the END TRANSACTION toolbar button ‘Add Transactions During Recording Transactions Figure 4-11 Adding Transactions During Recording, To add a Transaction during recording: 1. Click the START TRANSACTION button just before performing the step to be measured, Type a meaningful name for the Transaction. 2. Type a Transaction Name and click OK, ‘Add Transactions During Recording 415 Transactions Add Transactions During Recording - Continued Figure 4-12 End Transaction 3. Continue performing all the user steps for process to be measured 4. Click END TRANSACTION button. If there are multiple transactions select the transaction name to end from the list. Otherwise the default transaction will be automatically displayed. 416 Add Transactions During Recording - Continued Transactions When to Add Transactions? Add Transactions * Whenever you are accessing a new page. * When you submit data to the server * Whenever you want measurement. In this scenario add all the fines in one transaction * For any business process that you have planned for in the planning stage and any business process that you want timed. Note: It is common practice to add a “wrapper” transaction that includes the entire script so the transaction starts at the top of the script and goes till the end of the script. This transaction gives an idea of how long the entire business process took.Remember that the transactions must begin and end within a single action, Can not be extended over multiple actions. When to Add Transactions? 417 Transactions. Recommended Transaction Naming Conventions * Should make sense to the business owner or to the people who will read the reports, * Transaction names must be unique within your s ript, even between actions. * Should be short and always accompanied with a comment. For example, ys Trans Comment: Go to ” Ir_start_transaction (*CFR_01_PriceLookup") Lr_end_transaction(*CPR_01_PriceLookup”, LR_AUTO); Note: Explanation of the transaction naming ceR_01_Pricetookwp — CPR signifies the business process CreateFlightReservation = 01 denotes the first transaction within the script cokup points to the business process 4-18 Recommended Transaction Naming Conventions Transactions Check Replay Log ‘Mpa ones ese fe Te eee pr Je sepent.y mola) ile tell) Bee tre AE Se Last Replay Summary ast omctory: results aepiay status: No errors detected You snout {epics ty eampara e 20 a oboraeanapecie ne hep, Verification: check neha ono the reply acca amltes Your rocrdec session compu he Relay end ecorded montane noo. ‘You ean gat fatnarintrmaton abet th repay ram (be Ganaeteseie, or ome kan a. Thetp:/ /ieeatnost /thages/toolbar cool provile.qit” in Whi “Ata //ocaihost/inages/tocinax/tool -suppeze git’ is in the cache « ‘action.c(17: itp: //lecaihost/images /eoolbsz/tool contact git" ie in the eache sRetlonce{i7): Found resource *neep: //iooalnest hagas fuasts /ease_fighefinder.aif™ in WML Tpetioure(at): Resounee, *netp://Lovaihost/imagas/apacer.git" ts ii the cache alreacy ard wit Jhetion.e(27}: Found resolizce “Mittb: //iocalnost /images/forms/continue.gif in BTML thet // ‘Rotionsc(i7}; web submit data"com mercuryeours.servict, Sianonserviet") was successful, 272 Aetionse (ae): Hotiey, Pransaction “ciga-tn' enced with "vase" status (Duration: 3.4545) Figure 4-13 Replay Log Displays Transaction Duration ‘After you run the script, check the status of the Transaction in the log. The REPLAY LOG. will display the status of each Transaction in the script. The data in the Transaction step also includes the duration of the response between client and server. ‘Check Replay Log 4-19 Transactions Automatic Transactions 4-20 | Tanto | Cees noo TF coanenoe ‘ae F potorain tw st Siem | petomeeett ti tag ‘Automatic Stes | wae angen transaction “Entaun | Me nnwancane wseowots [OE] _ cat ftw Figure 4-14 Automatic Transaction Settings You can instruct VuGen to handle every step or action in a script as a Transaction. This is called Automatic Transactions. VuGen assigns the step name as the name of the ‘Transaction, And this is one of the main reason to rename your steps. By default, Automatic Transactions per action are enabled. Automatic Transactions will not show in the REPLAY LOG, but will show up in CONTROLLER VUSER LOGS. Automatic Transactions per action can be defined for all protocols, Automatic Transactions per step can be defined only for web scripts. To enable automatic Transactions per step, check the DEFINE EACH ST TRANSACTION check box. ACH ACTION AS A To enable automatic Transactions per action, select the DI TRANSACTION chieck box. If you disable automatic Transactions, you can still insert Transactions manually during and after recording. Automatic Transactions Transactions Summary © Use Transactions to measure steps in the business process. — End-to-end response times of speci — The entire business process © Transactions can be added during and or after recording, ‘Summary 4-21 Transactions Exercises 4-22 Objective: In this exercise you will add transactions during recording and after recording to the seript. Part 1; Add a Transaction During Recording 1. Create a new script. GF 8) On the START PAGE under SCRIPTS tab, click the NEW VUSER SCRIPT button, or select FILE > NEw from the VuGen menu, The NEW VIRTUAL USER dialog bbox opens. b) Select NEW SINGLE PROTOCOL SCRIPT and from the AVAILABLE PROTOCOLS lists select We® (HTTP/HTML), and click OK. ©) This opens the script in a new tab anc Introduction to Script Creation page gets displayed, 2. Click the NEXT button to move to the RECORD APPLICATION task. 3. Set options to make sure that the VuGen closes the Application under test and the Recording Level is HTML. a) Click the OPEN RECORDING OPTIONS link under the RECORDING OPTIONS section of select TOOLS > RECORDING OPTIONS to open the dialog box. b) In the GENERAL: SCRIPT node, select CLOSE ALL AUT PROCESSES WHEN RECORDING STOPS. ¢) In the INTERNET PROTOCOL: RECORDING node, HTML-BASED SCRIPT should be selected as the Recording Level. d) Click OK to close the dialog. 4, Start recording into "Action." a) Click the NEXT or START RECORDING bution, The START RECORDING dialog opens. b) In the Progrant to Record box, make sure "Microsoft Internet Explorer” is selected or choose from the drop list. ©) If the following URL is not already present in the URL box, then type it i: Exercises Transactions hetp: //localnost/servlets/com.mercurytours servlet welconeserviet d) Inthe Record into Action field, make sure it shows "Action" or choose from the drop list. ©) Leave RECORD THE APPLICATION STARTUP checked, and click OK. In the browser, sign in to Mercury Tours as "jo 30." 2) In the browser, sign in to the Mercury Tours web site as jo jo using the password bean. b) Click the SIGN-IN button. ©) Wait for the FLIGHT FINDER page to appea 6. Start a Transaction to measure the time it takes to get to the itinerary page, a) Click the INSERT START TRANSACTION bution [49° from the floating Record toolbar. The START TRANSACTION dialog opens. b) Type get_itinezary_page in the NAME field, and click OK. 7. Navigate to the ITINERARY page. a) In the browser, click the ITINERARY link. 8. End the get_itinezary_page Transact n. a) Click the INSERT END TRANSACTION button a” the floating Record toolbar. The End Transaction dialog opens with g already in the TRANSACTION NAME box. :_itinerary page bd) Click OK. 9, Inthe browser, click SIGN-OFF and wait for the SIGN-ON page to appear. 10. Stop recording and save the script as: Trans_dur_rec: Exercises: 4-23 Transactions Ww What functions were added to the script? HINT: Look in the TREE ViEW by selecting View > Tree ViEw. t_irinevary page measure? (Provide the formal step NE Wher step name doe name.) 11. Play back the seript a) Click the NEXT button on the WORKFLOW VIEW Io move to VERIFY REPLAY task, b) At this stage we want to see if the script replays without any errors so we will not bother with any settings, Click Start REPLAY button on the VERIFY REPLAY step or select VUSER —> RUN from the VuGen main window. 12. Accept the default results directory. a) The SELECT RESULTS DIRECTORY dialog box opens. b) Accept the default name reswiti and click OK. _itinerary_page Transuction take? Notify Transaction age ended with Pass status....", or use Find [er r1+ works only if you are in TREE VIEW.] W In the REPLAY LOG, how long did the ge (HINT: Look at the blue fine that begin get_itinera to search 13. Close the Test RESULTS window. Note: If you do not see the Test Results window then select View > Test RESULTS. For the next time make sure that you have the right setting in the General Options setting to display the test results. Refer to the Replay lab exercise to see how to set this. Part 2: Add a Transaction After Recording 1. Open the tran dur record script created in the previous exercise and save as ‘Tean_att_zecording. Work with the core script 2. Make sure you are in WORKPLOW VIEW. 4-24 Exercises Transactions a) VIEW TASKS button is selected and you do not have ScriPr or TREE VIEW buttons selected on the VuGen main window, 3. Insert a start transaction step to measure sign-in performance. a) Make sure you are on the Transactions task. i. Click NEXT button until you move to Transactions step, if you are currently on Verify Replay or Introduction step.This will open the Transaction Editor. b) Select the thumbnail com.nercurytours servlet .SignonServiet, ©) Now click on the NEW TRANSACTION button, The cursor turns into a hand icon and contains the start transaction icon. d) Click at the left side of the selected thumbnail com.mercurytours servlet .SignonServiet . This places the Start ‘Transaction icon at the beginning of the thumbnail. e) Now the cursor shows the end transaction icon. W Where will you insert the End Transactien step? 1) Click on the right side of the thumbnail. This adds the End Transaction icon Type sign_in in the edit box and press ENT Save the script. W How many transactions can you see under the under the Transaction Name list? Exercises 4-25 ‘Transactions 5. Run the modified rran_att_zecord script. a) Select VusER — RUN or press the RUN button on the VuGen toolbar. 6. Accept the default results directory. a) The SELECT RESULTS DiRECTORY dialog box opens, b) Accept the defuult name resuit2 ard click OK. NE How long did the ssgo-sn wansaction tke? 7. Once you are done, close the TEST RESULTS window and the script(s). Challenge Exercis Part 1: Add a Comment 1, Open the rs 1_aft_record script. Switch to TREE VIEW in the WORKFLOW VIEW, 3, Select the step above the Start Transaction Sign-in step. 4. From the VuGen main menu select INSERT > COMMENT. 5. INSERT COMMENT dialog opens. Type in a comment and click OK. 6. Save the script. Ww Why should the step above the transaction be selected to add a comment? Part 2: Observe the Impact of the Think ime 1. Open the teans_Thinktine script from \Training\vG81Seriptingfor 4-26 Exercises Transactions: a) Make sure you on the STart PAGE tab. b) Click on OPEN EXISTING SCRIPT button. This opens OPEN VIRTUAL USER window. c) Browse to the \rraining\GB1Seriptingfor web\Script folder. d) Select trans_thinkTime script ©) Click OPEN. This opens the script in a new tab. Run the script without making any changes. 3. Review the REPLAY LOG. WwW How long did the sign-in transaction take in seconds? How did the Think Time contribute to the transaction time? 4, Move the Think Time statement outside the transaction, a) In TREE View you can - drag and drop the think time step outside the end transaction statement. b) In Scetpr ViEW you can - cut and paste the 1r_think_time ( ) statement outside the end transaction statement, 5. Replay the script again. W ‘What is the time taken by the sign-in transaction? ww Write your observation of how think time impacted the duration of the transaction? Exercises 4-27 Transactions 4-28 Exercises Parameters Parameters Objectives After completing this chapter, you will be able to: * Explain what parameters are and how they work, Solve playback problems with parameterization © Parametetize a script for load testing. 54 Script Workflow Parameters Enhance Enhance Web Script «Transactions Parameters > * Correlation veritcation | Figure 5-1 Script Workflow The second enhancement topic Parameterization. In this lesson, the focus will be on how to make the script use varied data using parameters as compared to the recorded script which contains only the hard-coded input value, 5-2 Script Workflow Parameters Parameterization Recorded Script [San Francisco Select San Francisco (Parameterized Script }}————[Acapuico =] Rcspulce {London New York Paris Portland ‘San Francisco Seatle Sydney Zurich Figure 5-2 Unparameterized and Parameterized Example When recording a script, any selection you make is recorded as part of the script. If you're viewing a ticket booking site and you select “San Francisco.” then the value “an Francisco” is hard-coded into the script. To parameterize the script, you replace hard-coded data, such as the value “San Francisco,” with a placeholder. This, placeholder, called a parameter, is then used to introduce a variety of input values into the application during testing. Parameterizing the script eliminates problems that can cause errors in your testing or produce misleading load test results. Parameterization 53 Parameters, Why Parameterize? Varied input to mmm the application REAL USERS p| Static input to the application Recorded script (Virtual Users) ‘To Emulate real-world behavior and (o create realist results. Figure 8-3 Reason for Parameterization When a user is confronted by a choice on an application, the selection the user makes is based on his needs, preferences, and experience. Different users will make different choices. On the other hand, a virtual user will only make selections specified by the script. Ifthe script says "Select number four", then the virtual user will select number four every time the script is run, When a script contains parameterized data, virtual users can make varied selections. This makes a test much more true to life, and therefore much more likely to create realistic results, Why Parameterize? Parameters When to Parameterize Step When to Parameterize Unique Data constaint (> SteP2 Type username and password ce dependency| Step 3 Click on Sign-In button Step 4 Wait for confirmation {Data Step 5 Select a departure and arrival cities-— Ching constraint (——? St#P 6 Enter dates Step7 Enter credit card details Step® Click on Submit Figure 5-4 Common Reasons to Parameterize So far we've seen why it's important to parameterize. If you have a lot of input data, you may be wondering whether all of these fields need to be parameterized, Some data fields will need to be parameterized and some will not. ‘What situations require parameterization? There are four. Each situation, their causes and solutions, will be addressed in this lesson. ‘When to Parameterize 5-5 5-6 Parameters. Unique Constraint Registered users can sign-in here to find the lowest fare on patticipaing airines ‘Since user names are unique, User Name: [JO] jo’ can be used by only one Vuser. cay Find detailed FE) oration sboun your destination Figure 8-5 Unique Constraint ‘The first reason to parameterize is to accommodate any field that requires a unique value. While a virtual user is logged in with the jojo” username. any other user who tries to log in with the same username will get an error, causing a failure in the execution of the test script. Since each script will have to provide a unique usemame, a static value in a script will not work. The value must be changed to a parameter that will either retrieve a unique username from an existing list, or generate a unique username at run- time, Note: Most of the applications enforce unique login. But our training application Mereury Tours does not. Unique Constraint Parameters Date Constraint eg gh Foca eerh rh st ose alte yout ar gow he Wa (hen nt vur desiaion sy igh Deas Type: © Round Te one Way Poseager [T=] Depaning From: Reaemee =] om: [ir SP] naa Tero tevin: [as 27] Departure date works only for the current date ora future date. Prternces Sewsice Cass Economy ete © Byseese cass Figure 5-6 Date Constraint ‘The second reason to parameterize is date constraint. A date recorded into a script yesterday may be invalid today. This is a problem that can be remedied through the use of parameterization. Departure date works only for the current date or for a date in the future. For example a script generated a week prior to the test run worked fine on that day, but is now causing errors in the test execution. The problem is that you can only make a reservation for the present or future. This can be fixed with a parameter thet will always select a current date for the departure “eld. Date Constraint 5-7 Parameters Data Dependency Find A Flight Registered users can sig here to find the lowest fare on pattcipating airlines, The Password value is dependent User Name: [Jojo +7 on the User Name value. Both these Password: values have to correspond to log in successfully. Destinations Find detailed information about ‘your destination Figure 5-7 Data Dependency ‘The third reason for parameterization is data éependency, which applies whenever the parameterized value for an object on the application determines what values are valid for another object on the application. In the example above, the login Password is, dependent on the User Name. IF the username does not change, then the password will always match. If the User Name field is parameterized, however, then the value will change during test iterations. Since there will only be one valid password for each given User Name, the Password field is data-dependent on the User Name field. Hence, the Password field must also be parameterized with passwords that match the usernames Data Dependency Parameters Data Caching Unparameterized Script } UI VU; Average seek time ~ 2.5 sec am. The Select Next Row list allows you to specify how the data should be accessed from the data source. Select the Data Access Method for Data File Parameter Type 5-25 Parameters Sequential Method fev" [SEQUENTIAL | Vuser1 | Vuser2 | Vuser 3 Ee Iteration 1 Acapulco | Acapulco Acapulco Iteration 2 | London | London | London Iteration 3 | New York | New York | New Yor Figure 5-21 Sequential Method In the ‘Sequential’ method, each virtual user will use each of the rows in the Global data table one at « time, from top to bottom, Once all of the users have completed all of the rows of data, the testis finished, Use this mode wien you have an individual row of data for every iteration you want to run when there is no requirement for unique data, and when you are not concerned about the effects of data caching, 5-26 ‘Sequential Method Parameters. Random Method EES) paris RANDOM | Vuser1 | Vuser2 | Vuser 3 isudney Iteration 1| Paris Seattle London Iteration 2) London | New York | Zurich Iteration 3| Acapulco | Portland | Sydney Figure 5-22 Random Method In the Random’ method, each user will use a random row of data in each iteration of the test, Since the selections are entirely random, there may be times when two virtual users are using the same row of data, and data caching may have an effect. This is not necessarily different from real-life users who occasionally access the same data. Use this mode when you want to simulate the randomness of real users with the limited data caching that occurs in real-life transactions. Random Method 5-27 Parameters peas” [UNIQUE Vuser1 |Vuser2 | Vuser3 [fn francisco eens” Iteration 1 Acapulco | Paris Seattle fetrish Iteration 2 | London | Portland | Sydney an Iteration 3 | New York | crancigco | Zurich Figure 5-23 Unique Method In the ‘Unique’ method, the data table is divided into sections based on the number of users and number of iterations, Each virtual user will use a different row of data with each iteration, and no two users will use the same row of data during the test. Since no rows are re-used during the test, the maximum number of virtual users allowed during testing can be calculated by dividing the number of rows of data in the data table by the number of iterations that will be run. In the example above, since there are nine rows of data, and three iterations will be run, ‘no more than three virtual users can be used in the test. Use Unique mode when there are unique constraints on your data, Bear in mind that while no row of data will be re-used during the test, the data itseif is not checked, so it is up to you to make sure there are no duplications of data in the data table itself. Unique (by Row) Method Same Line as Method ERE (Io) UserName Ele Edt Seach Hep jojo jno roro Figure 5-24 Same Line as Method Parameters Password bean rean bow ‘The ‘Same line as ’ method assigns data from the same line as a previously defined parameter. You must specify the column containing the data, A list of all the defined parameters appears in the drop-down list. Note that at least one of the parameters must be assigned Sequential, Random, or Unique. ‘Same Line as Method 5-29 Parameters. When Creating Data Files in Notepad 5-30 2 Enter additional column names and values into the file using a delimiter such as a comma to indicate a new column, Begin a new line for each table row (for each row of data). Be careful to avoid putting in extra blank spaces, both in column names and data items. Create only one blank line and no more afer the last line of data, When Creating Data Files in Notepad Parameters Run-time Set Eo al ee ‘oon Fe al ee | teres | Ff eration count ya —____[e wevaimere FS =z should equal | ssinsmom | = la esteem Te etasal] RUMber of rows] Messer = Cane vatBick indata table |. "sn oe Fannie] _Onmitie "mn Eadtin (Powe ee | ee rn [fe | es ete [aren — a sesintan fee evan mom — SC ata on mapa | Lo “ oats Cma_|__ Figure 8-25 Number of Iterations Should Equal Number of Rows in the Data File If you are going to use data to support replay, then run the script at least once with data access as sequential. Make sure that the iteration count equals number of rows in data file in order to verify that all data values are valid, Once you are done testing all the data values, reset the number of iterations to 1. Run-time Settings - Run Logic 5-31 Parameters Verifying Correct Execution of the Parameterized Script Tavme ER LOR. Allows parameter data to be seen in the Replay ustous |] cot | tw Figure 5-26 Run-time Settings - Log ‘To see if the right data is being substituted in the REPLAY LOG, make the appropriate setting in the RUN-TIME SETTINGS To see parameter data in the REPLAY LOG, select EXTENDED LOG and PARAMETER SUBSTITUTION in the RUN-TIME SETTINGS, 5-32 Verifying Correct Execution of the Parameterized Script Parameters Viewing the RunTime Data ‘os a eT SS Ha Figure 5-27 Run To view a summary of the run-time data and the parameters as they are being used, see the Output window's RUNTIME DATA tab, You can track the script information that updates during replay using the RUNTIME DATA tab. During replay, click the rightmost tab, RUNTIME DATA. The tab contains two expandable/collapsible sections: © General: The general section shows the current iteration number. the Action name of the currently replayed step, and the line number within the script (SCRIPT VIEW). Parameters: The parameters section shows all parameters defined with the script and their substitution values based on the selected update method (sequential, unique, etc.). VuGen shows this information even if the parameter is not used in the script. Note: the RUNTIME DATA tab is not accessibie after the test run, since it only displays data that changes during replay. Viewing the RunTime Oata 5:33 Parameters Summary * Determine why and when to parameterize © To parameterize a script: — Determine which fields to parameterize. = Replace recorded values with parameters = Decide which parameter type to use. — Create the data file, — Populate the data fite = Choose the data access method and the number of iterations. — Run the script and analyze the results to verify correct execution. * Determine the data source for valid test data and the data access methods — Internal Data - Date/Time, Random Number, Unique Number, and Other = Data Files — Master and User-generared 5-34 Summary Parameters Exercises Objective: In these exercises you will determine which field to parameterize, then add a common parameter type to your script. Part 1: Create a Script to Register a New User 1. Create a new seript in VuGen, a) Click the NEW VUSER SCRIPT button on the START PAGE under SCRIPTS tab, or select FILE —> NEW from the VuGen menu. The New Virtual User dialog box opens. b) Select NEW SINGLE PROTOCOL SCRIPT and from the AVAILABLE PROTOCOLS lists select Wen (HTTP/HTML), and click OK. ¢) This opens the script in a new tab and Introduction to Script Creation page gets displayed. Note: If you were in TREE VIEW when viewing the previous script. Opening a new script will cause VuGen open the START RECORDING dialog box. If this happens then click CANCEL and move on to step Wo. 2. Click the NEXT button to move to the RECORD APPLICATION task 3. Make sure that the VuGen closes the Application under test and the Recording Level is HTML. a) Refer to the previous exercise to review how to setup RECORDING OPTIONS. 4, Start recording into "Action." a) Click the NEX'T or START RECORDING button, The START RECORDING dialog, opens. b) In the Program to Record box, make sure "Microsoft Intemet Explorer” is selected or choose from the drop list ¢) Ifthe following URL is not already present in the URL box, then type it in: http: //Localhost/serviets/com.nezcurytours, servle WelconeServie: d) Inthe Record into Action field, make sure it shows Action" or choose from the drop list. Exercises 5-35 Parameters ¢) Leave RECORD THE APPLICATION STARTUP checked, and click OK. In the browser, perform user steps to regi rer a new user. 2) On the WELCOME page, click the REGISTER button, The REGISTER page appears. b) ‘Type the information listed below for the fields in red. For the fields not listed here, leave them blank: UserName: steve Password: chevy Confirm Password: chevy cc} Click the SUBMIT button to add new user is to the database. vW \ the registration successful? What indicates that you have successfully created a new user account with Mercury Tours site? 6. Continue recording, In the browser, perform user steps for itinerary display. a) On the REGISTER page, click on the SIGN-IN link available in the confirmation message. b) Sign-in with the newly registered usemame and password. i. Name: steve ii, Password: chevy Click SUBMIT button, Ney Were you able to sign in with new usemame and password? How can you rel? 5-36 Exercises Exercises 1, 8. Parameters ©) Click the ITINERARY button. A query is sent to the database to search for all flights reserved for the logged in user name. The /TINERARY page appears and plays all values returned by the database in response to the query. ‘Stop recording and wait for the RECORDING SUMMARY page to appear. Save the script as ¢:\Training\vuGens. 1ser: ngForviep\Scriprs\sasicraran Part 2: Replay the Script BasicParam 2. Click the NEXT button on the WORKFLOW VIEW to move to VERIFY REPLAY task. if not already in the VERIFY REPLAY step. ‘At this stage we want to see if the script replays without any errors so we will not bother with any settings. Click START REPLAY bution on the VERIFY REPLAY step. Accept the default results directory. a) ‘The SELECT RESULTS DIRECTORY dalog box opens. b) Accept the default name cesuiet and click OK, Wait for the REPLAY SUMMARY to appear. What is the replay statu: ‘What is the description of the error? Open the TEST RESULTS window. a) Click on the VISUAL pSULYS Tink on the REPLAY SUMMARY page. This, will open the TEST RESULTS window. In Test RESULTS, find the step where error occurred. a) Expand all the steps. b) Goto the failed step sink: sign-in 5-37 Parameters ww ‘Was there an error message displayed on this step? If yes, what was the message? ©) _ Investigate further to reason step creation failed. i. Go the previous step of the failed Link: sign-in step. NY __Wasthere an err message displayed onthe submit Form com.mercurytours servlet .Regist message? ‘erviet step? If yes, what was the Ney How could you solve the problem revealed by the error message onthe Submit Form: com.mercurytours. servlet isterserviet step? 7. Close the TEST RESULTS window. Part 3: Parameterize the Script BasicParam Ww Define a unique data constraint, Nene Register page, which Fields do you think are likely to have unique da constraints? 5-38 Exercises Exercises Parameters Save BasicParam as UniqueParan. Click on the TREE VIEW icon, This will epen the script in TREE View. In the TREE View, which step contains the new user information? Rename the Submit Form steps according to the following table for easy identification. RECORDED NAME, NEW NAME Submit Form: WelcomePage commercurytours.servlet, WelcomeServiet Submit Form: com.mercurytours.servlet.RegisterServlet_ | NewUserInfo Submit Form: com.mercurytours.servleSignonServiet_ | Signin Open the properties for the step that contains the new user information. a) Right-click the step submit Form: NewUserinfo and select “PROP from the pop-up menu. The SUBMIT FORM STEP PROPERTIES dialog opens with the Daa tab displayed. From the table displayed under the Dara tab, write the field name and the value for each field with unique data constraints. FIELD VALUE Parameterize the USERNAME field. a) Click the ABC button EE] on the same row as the useetane value “steve.” ‘The SELECT OR CREATE PARAMETER dialog opens. b) Type usezaame in the PARAMETER NAME box. c) Accept the default PARAMETER TYPE “File,” and click PROPERTIES button, ‘The PARAMETER PROPERTIES dialog box opens, 5-39 Parameters 6. Create the data file. a) Click the CREATE TABLE button. b) Click OK to dismiss the confirmation message box. 7. Replace the first entry in the data file for the username parameter a) Click the EbIt WITH NotePap button. Notepad oper username. cae with the recorded value. . displaying the data file b) In Notepad, replace steve with cenze1 Ny Should you replace "steve" inthe de? 8. Add the remaining user names from the tuble below (0 username dat: a) Press ENTER after each data item, including the last one. Note: There should be three set of data values in your Notepad danze!, jackie and jet 9, Save the changes, and close Notepad, NY Wht the value of Setucr Next Row inthe Parameter Properties dialog? Based on this value, in what order would you expect VuGen to use the data in usernane.dat? 10. Click CLOSE to close the PARAMETER PROPERTIES dialog box. 11. Click OK to close the SELECT OR CREATE PARAMETER dialog box. 5-40 Exercises Parameters. W ‘What happened to the value "steve" that was in the use=Name field in the SUBMIT FoRM STEP PROPERTIES dialog? 12, Parameterize the PASSWORD field using password for the PARAMETER NAME. 13, Open the PARAMETER PROPERTIES for password. _W What is the suggested data file name in the FILE PATH box? 14, Create a data file for password and open it in Notepad. 15. Replace chevy with washington in the data file password. dat. a) Follow the same procedure you used to create a file and add data as for the parameter username. 16, Add the remaining passwords from the table to the data file password PASSWORD chan i Note: There should be three passwords in your Notepad washington, chan and li. 17. Close Notepad and save the changes to password dat. Ney _Usernane and password are dependent on each other, How will you ensure that the correct password is supplied to the correct username? 18, Ensure that dependent values are matched 5-41 Parameters a) Pick “SAME LINE AS USERNAME” from the SELECT NEXT ROW list. 19, Close the Parameter Properties dialog and the SELECT OR CREATE PARAMETER dialog when you have finished. Part 4: Parameterize a Field Using Existing Parameter wv Refer to the SusMIT FORM STEP PROPERTIES dialog. Which field uses the same data as the PASSWORD field? Parameterize the CONFIRMPASSWORD field using an exi 1g parameter. a) Click the ABC icon on the CONFIgMPASSWORD row. b) Click the down-arrow to open the PARAMETER NAME list in the SELECT OR CREATE PARAMETER dialog box ©) Select “PASSWORD” from the PARAMETER NAME list and click OK. Was the parameter “password” assigned 10 the field CONFIRMPASSWORD? Return to the VuGen main window. a) Click OK to close the Susur Form Srep Properties dialog. To be able to see the parameter values in the REPLAY LOG, What setting do you need to set? Change the RUN-TIME SETTINGS to run the script 3 times and to show parameter values in the REPLAY LOG. Exercises Parameters a) Click the RUN-TIME SETTINGS icon EP on tne toolbar or select VuseR — RUN-TIME SETTINGS from the menu.This opens the RUN-TIME, SETTINGS window. b) Make sure that the settings agree with those in the following table. Do not change other settings that are not in the table. NODE Run Logic ‘Sct NUMBER OF ETERATIONS to 3. Log Select EXTENDED LOG Check PARAMETER SUBSTITUTION, ©) Click OK to save the changes. Save the script UniqueParan Click on BACK TO REPLAY SUMMARY button, This will take you to the WorkFLOW VIEW Verify Replay task. Click the REPLAY AGAIN button, To run the script. Accept the default results directory. a) The SELECT RESULTS DIRECTORY dialog box opens. b) Accept the default name vesu2e2 of type a new name and click OK. Review the Last REPLAY SUMMARY results. Did the script iterate successfully? a a What were the results of exch iteration in the TEST RESULTS window? (HINT: Click the VISUAL. TEST RESULTS link to open the TEST RESULTS window, if not already open.) a Parameters v Was a new user name created for each iteration? (HINT: Look at the captured NewUserlnfo page for each iteration in tke TEST RESULTS window.) 9. Review the REPLAY Loa, a) Click the SHOw/Htpe Ourpur WINDOW {= icon. This will open the Replay Log. NYZ__Didthe ReMcay Loc ts the parameters you created and the values for each 5-44 parameter during each iteration? 10. Close the TEST RESULTS window, CHALLENGE EXERCISE (Optional): Part A: Parameterize to Use One Data File for Dependent Parameters Objective: In the previous exercise, you created separate data files for each parameter - usemame and password, In this section, you will create one data file that works for these two parameters, 1. Open sasicparam and save it as challengesameF ile. 2, Parameterize the log-in USERNAME and PASSWORD fields for the SIGNON SERVLET step, then close the SUBMIT DATA STEP PROPERTIES dialog. DO NOT ADD THE DATA YET. a) Follow the same procedure you used to parameterize these fields in the previous exercise, then close SUBMIT FORM STEP PROPERTIES without adding any data, 3. Open the PARAMETER LiST dialog box or select VUSER > a) Click the OPEN PARAMETER LIST toolbar button, eTER LIST 4. Create a data file called sign-in. dat. Exercises Parameters a) Select “USERNAME” from the list in the left pane of the dialog box. b)_ Inthe FILE PATH box, overwrite “username dat” with sign-in.dat ¢) Click the CREATE TABLE button. A data column, USERNAME, with one row of data, “jojo”, appears in the frame below the FILE PATH box. ‘Associate the password parameter with sign-in.dat a) Select “PAsswoRD” from the list in tke left pane of the dialog box b) Click the DOWN-ARROW button at the right end of the PILE PATH box and select “sSgn-in.dat” from the list. 6. Adda second column fo sign-in. cat forthe password. a) Click the ADD COLUMN button. The ADD NEW COLUMN dialog box opens with password already entered in the COLUMN NAME box b) Click OK, A second column called PASSWORD is added to sign-in.dat. The first data row contains the value “bean”. 7. Check the column associations. a) When you select a parameter from the left pane, the value in the BY NUMBER box (under SELECT COLUMN) should change. Make sure that “username” is associated with column 1, and “password” with column 2 of sign-in.dat 8. Add more data for both parameters 10 sign-in dat. 2) Click the Eprr wit NoTEPAD button, Notepad opens sign-in.dat showing the column headings “usemame,password” on line | and the first row of data “jojo.bean” on line 2. Starting on line 3, add each username and password (Separated by a comma) from the table to a new line of sign-in. dae. Do not add a space after the comma, Press Enter after each line (including the last Tine) b) Close Notepad and save the changes when you have finished. USERNAME PASSWORD denzel washington jackie ‘chan | jet hi 9, Ensure that dependent values are matched. Exercises 5-45 Parameters a) Highlight “passwoxp” in the parameter list, and pick “SAME LINE AS USERNAME” from the SELECT NEXT ROW list. 10, Verify and configure the RUN-TIME SETTINGS. a) Verify that the settings agree with those in the following table. Change any setting that does not agree with the table, Do not change other settings that are not in the table. Click OK to save any changes, NODE SETTINGS Run Logic Set NUMBER OF ITERATIONS to 4, Log Select EXTENDED LOG Check PARAMETER SUBSTITUTION. II. Save, then run chaLiengesamer ile. 12. Review the information in the Test RESULTS WINDOW, Ww Did the Vuser iterate successfully 4 times? 13. Review the information in the REPLAY LoG. W Did a different Vuser sign in each iteration? 14. Close the Test RESULTS window after you have finished reviewing the results, Part B: Database Issues 1. Open, then RUN chai tengesaneF ite ag: ww What were the results of the run? 5-46 Exercises Exercises Parameters Why did the run fail each time? a a One way to avoid the problem encountered in this exercise is to create unique data for every script run. What is a better way to avoid the problem? oe 547 Parameters, 5-48, Exercises Auto Correlation After Recording Auto Correlation After Recording Objectives ‘After completing this chapter, you will be able to: © Correlate dynamic values found by using show and resolve dynamic server values link 6-41 Auto Correlation After Recording Script Workflow Enhance Enhance Web Script + Transactions + Parameters + Verification Figure 6-1 Script Workflow ‘The third step to enhance a script is to perform correlation. In this lesson, the focus will be on automatic correlation after recording, In the coming lessons, we will discuss manual correlation and correlation before recording, 6-2 Script Worktlow Auto Correlation After Recording Replay of Script Indicates Error Last Replay Summary est Orectry rast replay status: Failed, Errors: ic Server Values (Correlations): Figure 6-2 Error In Replay Summary When the Last REPLAY SUMMARY indicates a REPLAY STATUS “Failed” and displays a message for Dynamic Server Values detected, this indicates that your script contains dynamic values and you need to perform correlation. Replay of Script Indicates Error 63 Auto Correlation Ater Recording Dynamic Value Recorded VuGen Script Login 1.Log in User Name jojo Password bean (User Name jojo Password bean) Response 2.Your sessionid@@e12345 (Session|ID@@@12345 ) Request for product info. 3.Request for product a — i (Se ID into GessionlD@@OI245 | oa op . Response 4.Product info found — Dynamic data is hard-coded in the script Figure 6-3 Dynamic Data Hard-Coded in the Recorded Script HTML pages often contain dynamic data, which is data that changes each time you access a site. In the above example, a user fills in his name and password, then submits, the form. When the form is submitted, a unique session ID number is sent from the server that identifies the user and allows for tasks to be performed, Although this session 1D number is contained in a hidden field in the HTML code, itis recorded by VuGen into the script, Dynamic data is correlated automatically by the client application (running in the browser) while recording a script. 64 Dynamic Value Recorded Auto Correlation After Recording Playing Back Dynamic Values VuGen Script 1.Log 4 Login -Log in User Name jojo (User Name jojo Password bean Password bean) Response 2.Your sessionid@@@12345 ies (recorded value) (SessionID@@@ 45678 ) Request for product info 3.Request for product info (SessionID@@@12345 ) Web Server Response ERROR SessioniD 12345 has expired Login again to get product info 4.Product info found Reusing recorded dynamic data will cause errors when you replay the script Figure 6-4 Replaying Dynamic Values ‘When the script plays back, the script creates the same requests to the server that were made during recording. For the home page, this is fine, there is no dynamic value. But after entering the login information and hitting the sign-in button, a live browsers (which was what we used to record) "correlates" these dynamic value, that is, the live browser receives the dynamic value that was generated by the server when navigating to the hhome page, remembers this value, and then passes the value back to the server on the login request. A VuGen script against a site that passes dynamic values between the client and server fails on playback, because the VuGen script plays back exactly what was recorded, in effect, ignoring this dynamic data, Playing Back Dynamic Values 6-5 Auto Correlation After Recording Solution - Correlate the Script VuGen Script Login (User Name jojo Password bean) 1. 2.Your 3. 4. Response Request for product info {SessionID@@@ 45678 ) Response Here is the requested product info Recorded dynamic data must be correlated using parameters Figure 6-5 Correlate the Script (SessionlD@@@ 45678 ) Web Server VuGen correlation is the process of enhancing the VuGen script to process the dynamic data pa ed between the client (browser, or VuGen) and server, just like a live browser. This enhancement requires several steps. VuGen must recognize that dynamic data is being passed between the client and server. Then the script is modified to capture the dynamic value that comes from the server into a VuGen parameter. Lastly, the script is modified to pass this value back to the server, similar to using parameter as we discussed in lesson Parameters, 6-6 Solution - Correlate the Script Auto Correlation After Recording Correlation Methods for Web Script © Automatic correlation can be done during of after recording Automatic correlation that can be performed in just a few button clicks. In this lesson the focus is on correlating after recording. Manually insert correlation functions This topic is covered in Manual Correlation lesson, Note: Regardless of which correlation method is used it results in the same script, Itis just a matter of which method you prefer Correlation Methods for Web Script 6-7 ‘Auto Correlation After Recording About Automatic Correlation After Recording 6-8 * To work correctly, automatic correlation requires at least one playback. * VuGen compares the web pages captured during playback to the web pages captured during recording. In order to identify the dynamic data being passed between the client and the server. * After playback, the replay summary will advice whether the script should be correlated because dynamic server values were found. Correlation after recording uses a built-in comparison utility. Allows you to view the text or binary differences between the recording and playback snapshots. You can then correlate the differences one-by-one or all at once, VuGen captures snapshots of the web pages during record and replay. VuGen then compares the recorded snapshot to any of the replay snapshots wlien the SHOW AND RESOLVE DYNAMIC SERVER VALUES link is clicked to determine which values need to be correlated to successfully run the script, ‘About Automatic Correlation After Recording ‘Auto Correlation After Recording To Correlate Automatically After Recording 1. Set General Options and play back the script. Review the Replay Summary. 3. If dynamic values were detected, scan for dynamic values. 4. Analyze the correlation results. 5, Correlate the dynamic value by pressing the Correlate button, 6. Verify correct execution, To Correlate Automatically After Recording 6-9 Auto Correlation After Recording 1. Set General Options and Playback 6-10 tr et tp tre [Fo | wo 1a! 2 tattend |B tstemee nce Hate sansa Wa ANIL) Be evecare, Last E ey 5 oe Dynamic? Peel ttl eon er en Scrmvawcr (COTTE panied nn eer oe ‘egg < GENERAL OPri0NS and select the CORRELATION tab, These options instruct the script to save correlation information during replay, to be used at a later stage, You can instruct VuGen to display graphies in the SNAPSHOT VIEW by selecting the DOWNLOAD IMAGES ON SNAPSHOTS VIEWER option. Also specify the type of comparison to perform when comparing snapshots: HTML or ‘TEXT, In most cases, it is recommended that you work with the default HTML comparison method. If your script contains non-HTML tags, then use Text comparison method. In the Advanced options, you can indicate which characters should be treated as delimiters. 1. Set General Options and Playback Auto Correlation After Recording 2. Review the Replay Summary Last Replay Summary 8 nesutobctory aut Replay status: Failed scisy EMR Errors: SGI ‘= roan, a cin 8 S85 Dynamic Server Values (Correlations): ae ee ait ye as Sa See et etetdneiee ana aera ‘eon seh tomate on eo on itn RESET —_ RET — | pea Oya Reet ed see NB Figure 6-7 Replay Results This Lasr Repay Summary clearly indicates that a dynamic value has been found in the script during playback and that you need to correlate the script, 2. Review the Replay Summary 6-11 Auto Correlation After Recording 3. Sean the Script for Dynamic Values ET Be) eGR Yon feet Ww bre Tob ncn tee JGR esmnoe eH vile UP [ie Dee yee SSS sao — Last Replay Summary j | eaeceana + past ect att [ern opi stater Failed assay + Errors: Dynamic Server Values (Correlatiors): a Click on this fr iia Verification: jure 6-8 Scan for Dynamic Values Once the replay results indicates that dynamic values were detected, s the dynamic values by 1g on the SHOW AND RESOLVE link. Clicking the link prompts VuGen to scan the s correlated. Once scanning is completed, VuGen opens the OUTPUT WINDOW and. displays the differences between the recording and replayed snapshots in the CORRELATION RESULTS tab. ript for dynamic values that need to be 6-12 3. Scan the Script tor Dynamic Values Auto Correlation After Recording Cal ae Oraied beh Bl ella Me 243 = eS le a ST sete bess, awe meen SRR errerraecner er eee Nile | fincas | BS fe oe onetvnee Hee ant aire sinmname - | (Dypaniovahes highightedin —P cence | Bebo Recorded and Repiayed snapshots a, aapiag | (a) Rosecrglon [9 Cavin hense | [) Gematintog ne ee Tee ‘es Dynamic values found in Racorded and Replayed script Figure 6-9 Correlation Results ‘The values to be correlated are displayed in the CORRELATION RESULTS tab in the OurpuT WINDOW. The columns, TEXT IN RECORDING, and TEXT IN REPLAY show the text differences between the snapshots. The next column, FIRST OCCURS IN, indicates the Action in which the correlation was detected. Clicking on the dynamic values in the CORRELATION RESULTS tab will highlight the dynamic values in the snapshots SERVER RESPONSE tab in HTML code. 4, Analyze Correlation Results 6-13 ‘Auto Correlation After Recording 5. Correlate the Dynamic Values eG tee pent veer tom Joie Mi ohh Prler |i eo awemed eg! yy ut sae EG al I: eee PBiercormewvinniia, |e Bae set pees, | SSE ses, ee + vor Reslay Brome Tay \ __ ss [Brciw | Bravest [canta] iecanie | —{b) Click on Correlate button | || stoebtewene fizaie =] sacar Tialescadaeiaeh = SS Figure 6-10 Correlating the Dynamic Values After VuGen detects the differences between the snapshots, correlate them individually, by selecting the dynamie values and clicking the CORRELATE button, VuGen also allows you to undo a specific correlation using the REMOVE CORRELATION button, 6-14 5. Correlate the Dynamic Values Auto Correlation After Recording After Correlation ee (PND te tk Ye fot i bow Tk en Sela lao sames ee Ole 19 (a) Bae sar _ oe eT Ss — rare © | tnten | Sakis [Tw] | | wectten BA nan tr nro tctng Slatsovamecconensenreoirsean |] PATI |lecrccoe eas assets san sane thar oar 3 tnt B rvten commencing. ‘re Correlation function inserted B= feces a to capture the dynamic value enter rt [Fees [Rasa [TBF comentons |B Gems | Stoel [RE] thane wochdiencnin Sectors a (mana [ream Tana maase Ie | Tio 544 ‘aha ‘ion a Green check indicates dynamic values correlated Figure 6-11 Script Correlated ‘Once you press the CORRELATE bution, VuGen inserts a web_req_save_paran function and a comment into your script indicating that a correlation was done for the parameter: Italso places a green check mark next to the dynamic values that were correlated. After Correlation 6-15 Auto Correlation After Recording 6. Verify Correct Execution a Tras egn te coeltion pete Figure 6-12 Replay the Script Once you have performed the correlation. Playback the script to make sure the parameter is able to capture and supply the dynamic value. Make sure there are no errors in the Replay Summary. 6-16 6. Verity Correct Execution Auto Correlation Atter Recording Summary ‘Summary Automatic correlation after recording: — Requires at least one playback of the script. — Detect the dynamic values by using the show and resolve dynamic server values link = Correlation Results tab displays the dynamic values. = Clicking the CoRRELATE button inserts the web_rea_save_param function and a comment into your script indicating that a correlation was created or performed for the parameter. 6-17 Auto Correlation After Recording Exercises 6-18 Objective: In these exercises you will reveal the dynamic server values and correlate the dynamic values found. Part 1: Create an Script to Reserve and then Delete the Itinerary 1 Note: Create a new script in VuGen a) Click the NEW VUSER SCRIPT buttoa on the START PAGE under SCRIPTS tab, or select FILE > NeW from the VuGen menu. The New Virtual User dialog box opens. b) Select NEW SINGLE PROTOCOL SCRIPT and from the AVAILABLE PROTOCOLS lists select Wes (HTTP/HTML) and click OK. ©) This opens the script in a new tab and Introduction to Script Creation page gets displayed. f you were in TREE VIEW when viewing the previous script. Opening a new script will cause VuGen open the START RECORDING dialog box. If this happens then click CANCEL and move on to step two. 2, Click the NEXT button to move to the RECORD APPLICATION task, Make sure that the VuGen closes the Application under test and the Recording Level is HTML, a) Refer to the previous exercise to review how to do this setup RECORDING Options. Start recording into "Action." a) Click the NEXT or START RECORDING button, The START RECORDING dialog opens, b) Inthe Program 10 Recard box, make sure "Microsoft Internet Explorer” is selected or choose from the drop list, ©) If the following URL is not already present in the URL box, then type it in: http: //localhost /serviets/com,mercurytours. servi Welconeservlet d) Inthe Record into Action field, make sure it shows "Action" or choose from the drop list. Exercises Exercises ‘Auto Correlation After Recording ¢) Leave RECORD THE APPLICATION STARTUP checked, and click OK. In the browser, perform user steps to reserve a flight. a) Type the login user name and password into the Mercury Tours Web site. User Name: 3030 Password: bean b) Click SIGN-IN. After logging in successfully, the FLIGHT FINDER page appears, ©) Select One Way from the TyPe radio button, d) Select I from the PASSENGERS list. ©) Select SEATTLE from the DEPARTING FROM list {Do not do anything on the ARRIVING IN list. g) Select FIRST class from the SERVICE CLASS group. h) Click the CONTINUE button, The SELECT FLIGHT page appears. i) Select the third (3rd) departing flight in the list, J) Click the CONTINUE button, The BOOK A FLIGHT page appears. k) Type the information listed below for the fields in red. Leave fields not listed here blank: First Name: Josey Last Name: #i21ians Credit Card: Master cara Credit Card Number: 1234567890 Expiration Date: 1¢ 2006 }) Click the SECURE PURCHASE button. The FLIGHT CONFIRMATION page appears with a success message and a confirmation number. 6-19 ‘Auto Correlation After Recording 6. Click the SIGN OFF link to reset the initial conditions. The Mercury Tours SIGN-ON page appears, 7. Stop recording and save the script as ¢:\Training\uGend. 1seriptingForveb\Scripts\NotCorrelated Part 2: Parameterize the Departing City Note: Here only high-level steps are outlined. If you prefer more detailed steps, refer to the Parameter lesson lab and parameterize the appropriate steps. 1. Save Notcorretated script as iesParan. 2. Switch to TREE VIEW. a) > TREE VIEW from the VuGen main window or click on the button on the VuGen toolbar. 3. Work with cit aie script and parameterize the FROMPORT field a Select SEQUENTIAL data access method. Note: Refer to Parameters lesson if you need detailed info on how to parameterize. a) Perform parameterization fo! mit Porm:...Reservationserviet step. b} Use depart as the PARAMETER NAME for FROMPoRT field. c) Leave the default value in the TOPoRT field. 4) Enter the values from the table below into the data file. Make sure to replace Seattle with New York. Press ENTER after each data item, including the last one. DEPART New York Ww What setting allows you to see the parameter values in the REPLAY LOG? 6-20 Exercises Auto Correlation After Recording Set the script to iterate 3 times and to show parameter values in the REPLAY LOG. Verify that the settings agree with those in the following table. Change any setting that does not agree with the table, then click OK, Don’t change any settings that are not in the table. [ Nove SETTINGS General: Run Logic | Set NUMBER OF ERATIONS 10 3. Select EXTENDED LOG. Check PARAMETER SUBSTITUTION. Check DATA RETURNED BY SERVER. Part 3: Replay the Script I 2. 7, Exercises Make sure you have cic iesPavam seript open. Go back to the Workflow View. a) Click on RETURN TO WORKFLOW button at the bottom lefi, when in TREE View. Click the NEXT button to move to VERIFY REPLAY task. Make sure that the following GENERAL OPTIONS are set in the DisPLAY tab. Do not change any options not in the table. This configuration will allow you see the playback of your script in RUN-TIME VIEWER. a) Select TOOLS + GENERAL OPTIONS. GENERAL OPTIONS, DISPLAY TAB VALUE Show browser during replay checked Click on the Srart REPLAY button. Accept the default results directory. a) The SELECT RESULTS DIRECTORY dialog box opens. b) Accept the default name cesuit1 and click OK. Review the Last REPLAY SUMMARY. 6-21 ‘Auto Correlation After Recording Ww What was the status of the script execution? What explanation does the LAST REPLAY SUMMARY provide for the script failure? ‘What suggestion is provided in the LAST REPLAY SUMMARY to resolve the problem? Part 4: Perform Auto-Correlation Note: We will talk more on the web_re: 6-22 Save the cities?aran script as Autocorzelated Replay the script again to capture the server generated data (On the Last REPLAY SUMMARY click the SHOW AND RESOLVE DYNAMIC SERVER, VALUES link, SCANNING FOR CORRELATION window will popup and scan the script. Do not interfere with this process. Wait for the scan to finish and for VuGen to display the results in the CORRELATION RESULTS tab. Were dynamic values listed in the CORRELATION RESULTS tab? Click on the dynamic vatues found in the CORRELATION RESULTS tab. As soon as the values are selected, they show up in the snapshot area with the dynamic values highlighted in the HTML code. Click on the CORRELATE button. VuGen inserts a web_req_save_param function and a comment into your script indicating that a correlation was created or performed for the parameter. It also places a green check mark next to the dyramic values that were correlated. 1» function in the coming chapters. save_p Exercises Auto Correlation After Recording 7. Correlate all the dynamic values displayed in the CORRELATION RESULTS tab. 8. Replay the script again and review the results. y Did the script show any errors this time? Note: If you still see errors in your script then try to do the correlation part again and speak to your instructor. Exercises 6-23 Auto Correlation After Recording 6-24 Exercises Verification Verification Objectives After completing this chapter, you will be able to: © Recognize why and when to use verification. Identify visual cues to check for during load testing * Add Text Checkpoints during and after recording. TA Workflow Enhance Enhance Web Sere [seret | |-Troreacone | -Parmters “Correlation Figure 7-1 Workflow Verification ‘The fourth step to enhance the script is the addition of checkpoints for verification. In this lesson, the focus will be on how to verify the script under load. 7-2 Worktiow Verification Functional Integrity for Concurrent Users Success Low Load One Vuser running the script Failure Increase in Load Script run under load with many concurrent Vusers Figure 7-2 Functional Integrity for Concurrent Users ‘A load test is always performed after functional testing. Attention should be paid to the functionality of the application while it is load tested to ensure that what worked correctly under low load still works correctly under heavier load. By adding Checkpoints in the script, you can verify functionality of the business, processes during load testing. Functional Integrity for Concurrent Users 73 Verification Test Specification Example Application Morcury Tours Web site Transaction Cteate New Order DDesenption: itis business process adds a now ordor inte the database. ‘Staring Page: | Mercury Tours Home Page hitp:thvww MarcuryTeurs.com Test Objective: | Verify the fctowing for 80%, 99% and at 100+% eapacty ‘Test Reguiraments: + Ticket purchase completed successfully, indirectly test the _| Test cases should include business processes that manipulate records from the database to place realistic stress on input/output processes & services, as well as \die-tier logic. Figure 7-3 Test Specification Yo ba ‘This is the sample test specification for the Create New Order business process for the What does ‘verify’ mean in load testing an application? Adding verification allows LoadRunner to check for functionality under load. This i site Mercury Tours site. The test objective is to verify the site’s functionality under load. important due to the potential for load to affect the business functionality adversely. Verification can identify whether the visual cues that confirm functionality are appearing as expected. These visual cues can be either text or images. Test Specification Example Verification What Indicates Success? Login| — See uepaaae sedan ces ee whaticaeasse ESSERE ticket was purchased successfully? : ‘See fight —*— Purchase kat | out barry as Boo yee Creo ctoaan ee ‘Conteve Shoparg Figure 7-4 Success of a Business Process What indicates sucess of a business process completion? In other words, what tells you that your order has been placed successfully with the Web site? ‘Sometimes a failure in your test wont show up as an error in your test run, To make sure that your business processes completes successfully, you can set verification points in your script. A verification point is used to verify that specific text or images appear ‘when expected in the test. Let's look at an exemple On this web page, the user enters information for purchasing a ticket, selecting departure and arrival cities, selecting date of travel and flight, When the user clicks the Purchase bution, one of two things happen. If the ticket is purchased successfully, a confirmation message appears, However, under heavy load, the system may not be able to book the ticket, in which case an error message Would appear. In both cases, the user can click Continue to move to the next page, No navigation problem is created that might cause the test to fail. We can measure how often this process is succeeding or failing by placing a verification point in the script. To check whether the confirmation message appeared to indicate that the business process was successful. What Indicates Success? 75 Verification Visual Cues Indicate Success or Failure of a Business Process 76 z nena { image Confirmation —________, Text Confirmation Flight confirmation image and text appear after pressing the Secure Purchase button Figure 7-5 Indication of Success or Failure of a Business Process indicate whether or not a business process was successful, Usually a confirmation order number, a thank-you message indicates that your order was placed with the Web site/application successfully. In this example, once a user clicks on the Secure Purchase button, a screen shows the flight confirmation image, "Itinerary Booked" text, and ticket details. The image and text both indicate that his order succeeded. In the case of an error, the application would have generated an error indicating a problem booking the ticket. Visual Cues Indicate Success or Failure of a Business Process Verification Steps Involved in Verification Expected __y Actual Fine = tVaue=S ) PASS igure 7-6 How VuGen performs verification when a Checkpoint is present in the script 1. Capture the information needed to perform verification. On playback, compare the actual value on the application to the saved, expected value. 3. Send the comparison result (the "status") as either PASS ~ Test requirement # 5 successful. OR FAIL — Test requirement # 5 failed. Steps Involved in Verification 7 Vertication What Information Should | Gather for Verification? Key information to gather: What are the test objectives? Are there specific items or values to be verified? What are the visual cues in the business transaction to test? What are the expected results? What Information Should | Gather for Verification? Verification Verification Method VuGen allows you to add Checkpoints for verification automatically and also programmatically. Adds web_reg. search for a specified text string on a web page. {ind function to the script In the web environment, VuGen allows you to add verifications called Checkpoints by the point-and-click method. You can add checspoints for images and text. In this less only text checkpoints are discussed. To learn about image checkpoints, refer to the online books. Verification Method 79 Veritication About the Text Check Function 7-10 Text Check adds web reg find function, web_reg_find is a registration type function. Registration means that it does not execute the search immediately, but performs the check while the page is being downloaded, Always appears in script before the step where the text to be checked appears, Add comments before the text check function to give a meaningful name to the text check. About the Text Check Function Veritication Adding Text Check to the Script ‘Text Checks can be added to the Script: 1, During Recording 2, After Recording ‘VuGen allows you to add a check that searches for a text string on a web page. You can add the text check either during or after recording, We will learn both the methods in this lesson. ‘Adding Text Check to the Script 7A Verification Text Check During Recording 1. Select the Text in the Browser a stata OO i fom Lan oe oe vee 009 Gun arm Gee VS STOW Cirad = Pryde Else 2 yicet— Slevews |} Depa ating Zale Acne TREESTE SS eu sua sin 90 een e eT Select the Text to be ve Figure 7-7 Select the Text to Verify ‘The Test Objective is to verify that the “Your itinerary has been booked” text appears after the SECURE PURCHASE button is pressed, Do the following: To achieve the above test objective, while recording your business process proceed until you have clicked the SECURE PURCHASE button. Once the page that contains the text to be verified appears: Select the text to be verified in the browser 712 Text Check During Recording Verification Text Check During Recording 2. Insert the Text Check 2. Click the ‘Insert Text Check’ button Figure 7-8 Insert Text Check 3. Click on the INsERr TEXT CHECK icon. This will insert awep_reg_#ing function into the script. Text Check During Recording TAB Verification Text Check After Recording 1, Select the Thumbnail ee i Muiesmers et orgie us cus ee eet very ex wae Sle a we ob Yok Orch Snapshot vier itis the ight S—$—$____—_— page | aE See An * (4, Select the aeons | thumbnail i and. | FLIGHT CONFIRWATION Ce Your itinerary has been booked! caw Fraphar to London ESSE Ta he She Aes 209 neh : ouch {Ban A Ui At 2 Sine ot Figure 7-9 Select the Thumbnail Note: Make sure that you are on the Content Checks task step in the Workflow view Select the thumbnail and verify in the Snapshot view that you have selected the right thumbnail, 714 Text Check After Recording Verification Text Check After Recording 2. Select the Text to be Verified in Snapshot View NC Re lolx FB Ci Yaw pont ner Atos Tees Wrsow Ep Slot] Li @aethwod hm Bally UD :[Ramll sve te | Bisefams [Sesecoraial web OTPROVA) | Tentheck- web (HTTRIAMO) | ‘asks ‘Select tem ard od 9 Tent Check cae ae Sees [a] Soa | sendesenie | +Roestmer amen wert tata Ag a a cemhancemente + 2. Select the text Fiz tobe verified Fort, eas Figure 7-10 Select the Text in the Snapshot View Once you are on the correct page, select the text to be verified by highlighting it in the SNAPSHOT view. Text Check After Recording TAB 7-16 Verification Text Check After Recording 3. Right-Click and Select ‘Add a Text Check’ EAL Sew set ger ine Dok ne Fr Gl se) Bi esatnees py on gl alt Sip [Fame Bs te 1S) (Gai Javencoranr wm omiprve | Tentnec wes GTP] Tl So teed ooo oak ec ecteten sani -nm ; srorpreenery? | er = | Bock Meat piers yh | a 3. Select ‘Add x = For Hal, ress i a Text Check ‘Copy Saecion Figure 7-11 Select ‘Add a Text Check’ from the Pop-up Menu Right-click on the selection and select ‘ADD A TEXT CHECK (WEB_REG_FIND)’ from the pop-up menu.. This opens the FIND TEXT dialog box. Text Check After Recording Vettication Text Check After Recording 4. Verify You Have the Correct Information a Seatch for soci Too Gat toaay harteenbooked ~S © sasehf Yori See" Verify correct text here =) F is et TRG T ee tions Use” esavildoad tor] sbharemetoa choices FF Nachone 7 eeaay dia 7 Use fx oy da F Use" or awitoat ttf 2] obtener chains F Reachie) «= ow SC TF Save count Feat co | Figure 7-12 Verifying the Text Check Info In the Find Text dialog box verify that you have the correct text and click OK. This adds the text check to the script. Note: The best way to check whether a check has been added is to switch to the TREE VieW and look for the function. Text Check After Recording TAT Verification Verifying Success of Text Check 7-18 8 2 rnemnnen Oe aol anaucrtont se Test Result indicates ‘success of checkpoint. Tig Sent an nertn CA Sante cng Tif sectors oFasameranccan nesses LB ine ot Berroa ly Figure 7-13 View Replay Log and Test Results Once the Checkpoint is added, replay the script. To make sure that the text check pass view the Replay Log by clicking on the REPLAY LOG link in the Last Replay Summary. Alternatively, view the success of the Checkpoint in the Test RESULTS by clicking on the VIEW VISUAL TEST RESULTS link. Veritying Success of Text Check Verification Classroom Discussion Where is the text check added? Classroom Discussion 719 Verification Checking for an Error Page 7-20 Q If you cheek for an error page and the error page is found, should the script pass if this check passes? &: How do you change a check’s pass to a fail and vice versa?” PB eyaweee ig Figure 7-14 Checking for an Error Page What if you are checking for the appearance of an error page? Should the script pass if this Check passes? The answer is no, Therefore you would need to set the Success on not found setting for this Check. Note that in this example, the test should pass if the error text is NOT found. To set the text check to fail, even if the specified text is Found do the following: 1. Open the FIND TEXT dialog 2. Select the FAIL IF check box. 3. Select “FOUND” from list. 4. Click OK. If the specified error check is found, VuGen will report it as a fail. Checking for an Error Page Verification eee al o> 933 a omer oe ern TD wom sat} eal nnn = 3) ns FS Figure 7-15. Visual Cue Dependent on Parameter ‘An instance when an expected visual cue is dynamic is when the visual cue’s value is, dependent on the input data from a parameter in the script. How can you check for these values that change from one iteration to the next? Checking Visual Cue Dependent on Parameter 7-24 Verification Add Parameter Name to the Text Check SD sewhtneitc ten [Bee ar © bchome F enzy dae © Seu Tenty wat and endo 29 igure 7-16 Parameter Name for Text Check You can assign a text check to look for values that exist in the Data Table. This is an effective way of verifying the appearance of a parameterized value. To assign a parameter to the text check, do the following 1, Click the DaTA-TABLE button in the SEARCH FOR SPECIFIC TEXT box. 2. Select the appropriate parameter name from the list and click OK, 7-22 ‘Add Parameter Name to the Text Check Verification Good Practices * Determine the visual cues to verify for each business process during the planni stage, © Add text checks during recording. One reason to add checks during recording is that it might be easier than trying to remember where they should go by looking at the recorded script, especially if you are unfamiliar with the application under test, * Give the text checkpoint a meaningful name by adding comments that describes what is being verified. Good Practices 7-23 Verification eb (wre The reson | aeticone | Save Rooms | eee tesa veces | fe pas wrteeal in tbe eee Cnet antmana SS cto CSS chet [EEE ET EEE [CE Jscnsuiy BOOK A FLIGHT 2.Eahancemen Ploasereviw your travel tneary and |e ‘Summary Figure 7-17 Comments for Text Checkpoint Steps for adding comments for a text check: 1, Select the step preceding the text check. Select INSERT > COMMENT from the menu. 3. This opens the INSERT COMMENT dialog. Type a meaningful comment and click OK. This will add the comment before the text check function. Note: Comments can also be added while recording from the floating toolbar. 7-24 Adding Comments for Text Checkpoint Veritication Summary © Determine visual cues to check during load testing, © Text checkpoints can be added during or after recording, * Recommended method is to add text checkpoints during recording, ‘Summary 7-25 Verification Exercises 7-26 Objective: In this lab, you will create a script to book a flight. During and after recording you will add the checks necessary to verify the business process. wv Why is it recommended that you add verification checks to your script? Part 1: Add Text Check to a Script During Recording Note: If you were in TREE VIEW when viewing the previous Create a new web script, 2) Click the New bution Pon the VuGen toolbar or select FILE > NEW from the VuGen menu. The NEW VIRTUAL USER dialog box opens. b) Select NEW SINGLE PROTOCOL SCRIPT and select WEB (HTTP/HTML). ©) Click OK. d) This opens the script in a new tab and Introduction to Script Creation page gets displayed. pt. Opening a new seript will cause VuGen open the START RECORDING dialog box. If this happens then click CANCEL and move on to step two. 2, 3 Click the NEXT button to move to the RECORD APPLICATION task Make sure that the VuGen closes the Application under test and the Recording Level is HTML. a) Refer to the previous exercise to review how to do this setup RECORDING tions. Start recor opens, b) In the Program to Record box, make sure "Microsoft Internet Explorer” is selected or choose from the drop list. Exercises Exercises . Enter the passenger and credit card information in the BOOK A FLIGHT page. Verification ©) Ifthe following URL is not already present in the URL box, then type it in: heep: //Locaihost/serviets weiconeserviet m mexourytours.servies d)_ Inthe Record into Action field, make sure it shows "Action" or choose from the drop list. ©) Leave RECORD THE APPLICATION STARTUP checked, and click OK. In the browser, sign in to the Mercury Tours web site as jo jo with the password bean. Enter the flight details to search for available flights, Accept the defaults for all fields in the FLIGHT FINDER page except those shown in the table below FIELD VALUE Departing From San Francisco Arriving In New York Click CONTINUE. Accept the first available flight for both directions of the round trip. Click the CONTINUE button on the SELECT FLIGHT page. Add a Start Transaction step called purchase_fLight.IF you need help with this step, please refer to the Transaction lesson. 2) Use data from the following table. FIELD - VALUE First Name Toseph Last Name Williams | Number | «987654321 Click the SECURE PURCHASE button. Create a check to find the text, “Your itinerary has been booked.” 7-27 Verification a) Highlight the text “Your itinerary has been booked” in the browser (omit the exclamation point). Note: If the floating toolbar shows an increase in the number for events, this signifies that the check has been added, b) Click the INSERT TEXT CHECK button on the floating Record toolbar. 14, End Transaction pur the transaction lesson, ase_fLight. If you need help with this step, please refer to 15, Stop recording. Click the Srop button Ml in the floating Record toolbar. Ney Wheetype of function was added tothe seripr? HINT: Look in TREE VIEW. 16. Identify the text check as veri fyttinerery. 2) To identify the text check, click the VIEW > TREE VIEW or click the TREE ‘VIEW bution in the toolbar. b) Find the wep_reg_find text check in the script and enter the following comment text on a separate line immediately above it: //Niewizinerary by selecting INSERT — COMMENT from VuGen main menu ©) Make sure that the comment appears above the text check function. If it does not then drag and drop it above the function 4d) Verify that the comment exists by viewing the script in TREE VIEW. 17. Save the script as veri ication and then run the script. 18. Review the details of the checkpoint, a) On the Last REPLAY SUMMARY Click on the VISUAL TEST RESULTS link, This opens the TEST RESULTS window, ifthe TEST RESULTS window is not open. b) Expand the ITERATION I step in the TEST RESULTS window. ©) Click the text check function SERVICE: REG FIND. 7-28 Exercises Verification _v How does the result for the text check step show that the check passed? 19, Close the TEST RESULTS window and Verification script Part 2: Add Text Check to a Script After Recording 1. Continue working with verification script 2. Make sure you have the script open and you are on the Content Check task in the WorkFLow VIEW. Note: If you are in TREE or ScRIPT VIEW, clicking on the RETURN TO WORKFLOW button takes you back to the WORKFLOW VIEW. ww visual clue will indicate that the sign-in was successful? Exercises 3, Verify that sign- wuccessful a) Select the Thumbnail called ‘com.mercurytours.servlet,.SignonServiet’. This, opens the thumbnail in the SNAPSHOT VIEW. b) Verify that you have the correct page. In our example, we want to see that sign-in was successful and appearance of FLIGHT FINDER page indicates this. 4, Select the text “Use our Flight Finder’ in the SNAPSHOT VIEW by highlighting it. 5. Right-click and select AD A TEXT CHECK (WEB RI menu. This opens the Find Text dialog box. 86_FIND) from the pop-up 6. Make sure you have “Use our Flight Fincer’ text under the SEARCH FOR SPECIFIC ‘TEXT edit box. Click OK. This adds the text check to the script. 7. Save and run the script. 8. Accept the default results directory or type a new name, 7-29 Verification 9. Verify the success of the text check by viewing the Test RESULTS and REPLAY Los, 10, Once done, close the TEST RESULTS window and the script. 7-30 Exercises GS Actions Objectives ‘After completing this chapter, you will be able to: © Create multiple Actions for a web script * Configure Actions to achieve load testing goals. B41 Actions What is an Action in VuGen? Action = In VuGen is a set of recorded user steps in a s particular user task through script iteration, ript that allow you to emulate a VuGen allows you to emulate user activities by grouping tasks sections called Actions. There are three default Act ions that a new script contains: vuser_init, Action and vaser_end, You can add more actions if your load testing goals demand it ‘An Action is composed of steps Each step can be: = Auser step = A LoadRunner enhancement step 8-2 ‘What is an Action in VuGen? Actions Script Recorded in Single Action eGR Yow wt har Bone Togs wnew Hap {Fiaeno ecorded aropet, cick Ror’ Again a rerecord the he nlc buns pats wae Selo la femames wu ole : (ati | vonomess web GHTTPAATM | [re x | mcs Recording Summary POSTS | Protncols ‘eee sine Sratacch Soiucted Dato waagenerored | jem a ‘Shows that user || ‘ere ‘steps wore in just | eer == eS] fale pea = ure 8-1 Single Action Script * So far you recorded all steps of the business process into a single action - Action, © Figure 8-1 illustrates the user steps recorded in a single Action. Script Recorded in Single Action 8-3 Script Recorded in Mul a4 Actions. ple Actions Betz tt emer Ten 3 ple dd (aici ames Recording Summary " Protocols SSS, enti eet re a esp [iene 2 oot Figure 8-2 Multiple Action Seript © Figure 8-2 shows three business processes (Log in, Create New Order and Logout) recorded in a separate Actions. ~ Login recorded in Vuser_init = Create New Order in Action = Logout in Vser_end Every script contains three primary sections: vuser_init, Actions, and vuser_end. You can instruct a seript to repeat the Action section when you run the script. Each repetition is known as an ireration, The vuser_init and vuser_end sections of a script are NOT repeated when you run multiple iterations, Script Recorded in Multiple Actions Actions Why Record the Script with Multiple Actions? 1. Seripts can be divided into logical sections (Actions), like the main sections of a business process, or by specific business process. 2. Multiple actions help you design more modular and efficient scripts, Why Record the Script with Multiple Actions? 85 Actions Relate Planning Information to Actions Base Actions on Vuser models or test goals. Example Actions = Log in - Vuser_init Create New Order - Action Modify Order - Action? — Logout - Vuser_end It is important to use information gathered during planning to help you determine: — What user steps should be grouped? — How many “Actions” should be in the script? — What initial and end conditions of each Action will allow the script to iterate successfully? 86 Relate Planning Intormation to Actions Actions Classroom Discussion - Planning a Script Based on information gathered, web script should be recorded as: © Login * Select three different item and place it in the shopping cart + Purchase the items * Logout Discu section What steps will go into Vuser_init, Action and Vuser_end section? Which ll you iterate and for how many tires? Classroom Discussion - Planning a Script 87 Selecta Action section Figure 8-3 Record Script with Actions Steps to record a script with Actions: 1. Start recording. 2. Select the Action file where you want to record the steps. 3. Record user steps in the appropriate Action fite, 4, Repeat steps 2 and 3 as necessary. 5. Stop recording, Note: You cannot go back to a previous actior while recording. For example. if you go from Action? to Action3 you cannot go back and record anything in Action2, 8-8 Greate a Script with Actions Actions ‘Always ond at this page if the next iteration is Sign-on oF Register End Step Figure 8-4 Understand the Initial and End Conditions You do not want to create new Action just anywhere. Any Action that will be run through multiple iterations should start and stop on the same page. For the test to iterate successfully, the action must reset to its original page, screen or values before beginning the next iteration, Correct Initial and End Conditions 8-9 Actions Record Login In Vuser_init or Not? 8-10 Answer these questions: © Should each Vuser log in as a different user on each iteration? * Should login be iterated frequently? © Do you want to measure the response time for the login? * Will you want to measure the ramp up effect on the logi If the answer to any of the above questions is yes. do not want to record the log in vuser_init. Why? Because when you run this seript from the Controller, you will not able to achieve the above goals. Always keep load testing goals in mind when recording a script. Record Login in Vuser_iit or Not? Actions Action Blocks ae fue | hee ————— | [EG seemstnesine [ES Memon | Pte reecttn "Sedum 2 OT a ie ee cet | | eae onsen Figure 8-5 Actions Grouped in a Block Action blocks are groups of actions within your script. When running scripts with multiple actions, blocks help you with grouping allowing you to iterate some actions more frequently than others. 1. Create all of the desired actions through recording or manually. 2. Open the RUN-TIME SETTING. Select the GENERAL: RUN LOGIC node. 3, Add a new action block. Click INSERT BLOCK. VuGen inserts a new Action block at the insertion point with the next available index (Block0, Block |, Block2). 4, Add the desired actions to the block by Clicking INSERT ACTION and then by selecting the actions from the Actions list, Action Blocks. 8-11 Actions. Classroom Discussion - Configuring Actions Based on Load Testing Goals 8-12 Load Testing Goal: Emulate a purchasing agent logs-in in the morning, and logs out at night, In one day the agent: * Creates 20 purchase orders * Modifies 5 purchase orders + Searches for 10 orders. But Modify cannot be performed with out search business process performed first, How should the script be recorded? How many iterations? So in answer to the classroom discussion a bleck can be created to include Modify and Search actions. As Modify cannot performed without the Search action. Leading to the fact that Modify cannot exist as a separate action - delete Modify when the block is created, We will discuss how to achieve the iteration count in the next page. Classroom Discussion - Contiguring Actions Based on Load Testing Goals Actions Action Block Properties Spee Sinden een eneosea oases Undsets [GE] _ crt | te Figure 8-6 Setting Action Prope You can set the properties of each block independently. The property settings are: Sequence: You can set the order of actions within your script. You can also indicate whether to perform actions SEQUENTIALLY of RANDOMLY. erations: In addition to setting the number of iterations for the entire Rum section, you can set iterations For individual actions or action blocks. Weighting: For action blocks running their actions randomly, you can set the weight or percentage of each action within a block. Allows you to iterate some actions more frequently than others Once the block is created, set the number of iteration to be 35 for Rum and set the properties for Run as Random from Properties. This will allow you to set percent individually and thereby match the load test requirement. Action Block Properties B13 Actions Weighting - Sequential Access Method 8-14 — ene Ne ] Sequences I= | | fee | Some metog p eae com | ‘iain Sas dizarnow alow | utes [BE] | we Figure 8-7 Sequential Method In the sequential mode, the script executes the blocks or actions in the order in which they appear in the Run section of the RUN-TIME SETTINGS. To set sequential access method: 1. Create the Actions by recording or inserting them manually. 2. Open RUN-TIME SETTINGS, RUN LOGIC node: 3. Right-click RUN, and select PROPE! 4, Select SEQUENTIAL from RUN LOGIC list and click OK. 5. Right-click RUN again, and select INSERT ACTIONS, 6. Double-click an action file to add that action to Run. Setting the Sequential access method in our example will not allow us to iterate the block of Modify and Search to desired iterations. So this setting will not work for our example. Weighting - Sequential Access Method Actions Figure 8-8 Random Method By selecting Random run logic, you can set the wei Feach Action, 1. Right-click an Action and choose PROPERTIES. The ACTION PROPERTIES dialog opens. Specify the desired percent for the selected block or action. In the RANDOM PERCENTS box, specify a percentage for the current action. The sum of all the percentages must equll 100. Note: The default Random percents is equal percentages for exch Action. In the Figure 8-8, that is 50% for each of the two Actions, For the example in our classroom discussion, set the properties for Rim as Random from PROPERTIES. This will allow you to set percent individually to match the load test requirement, You can arrive at the percent by using this formula: number of times the task needs to be done | total number of iterations. For example, Create Action needs to be executed 20 times, 20/35 =.57. So assign 57% to Create, 28% to Search and 14% to Modify&Search. VuGen prompts to say that it is, not 100%, so increase one Action or a block by 1% Weighting - Random Accoss Method 8-15 Actions Summary * Actions allow scripts to be divided into logical sections to match your business. processes. ‘* Remember to use the correct initial and end conditions when using multiple actions, ‘* Blocks help to group Actions so that some can be iterated more frequently than others 8-16 ‘Summary Actions Exercises Objective: In this lab, you will create a script to book a flight with the log-in, book flight and log- out in different Action sections, You will also create Action blocks and set Action block properties to match the test requirement, Part 1: Create a Multiple Action Script: 1. Create a new Web script a) Click the NEW VUSER SCRIPT button on the START PAGE under SCRIPTS tab, —+ NEW from the VuGen menu, The NEW VIRTUAL USER dialog b) Select NEW SINGLE PROTOCOL ScriPr and select WEB (HTTP/HTML). ©) Click OK. 4) This opens the script in a new tab anc Introduction to Script Creation page gets displayed. Note: If you were in TREE VIEW when viewing the previous script. Opening a new seript will cause VuGen open the START RECORDING dialog box. If this happens then click CANCEL and move on to step wo, 2. Click the NEX'T button to move to the RECORD APPLICATION task, 3. Set RECORDING OPTIONS. a) Click the RECORDING OPTIONS toolbar button, or select TOOLS > RECORDING OPTIONS to open the dialog box. [ Nove, RECORDING OPTION Script Select Cui 2 RECORDING STOPS. Recording Select HTML-BaSeD SCRIPT. Advanced Check RESET CONTEXT FOR EACH ACTION. Correlation Uncheck ENABLE CORRELATION DURING RECORDING. Exercises 8-17 Actions 8-18 Add a Action to the script a) Onthe VuGen main menu, click the CREATE A NEW ACTION toolbar button sg vorselect ACTIONS —> CREATE NeW ACTION. The CREATE NEW ACTION dialog opens. b) Type snowrein click OK. ry in the ACTION NAME field (overwrite “action2”), and Add a second Action to the script called hookF light. a) Click the CREATE A NEW ACTION toolbar button sor select ACTIONS > CREATE NEW ACTION. The CREATE NEW ACTION dialog opens. b) Type Bookr1ignt in the ACTION NAME field (overwrite "Action3"), and click OK, ©) Be0k# Light is added to the actions list following showitinerary Record log-in into the vaser_init action a) Select vusex_init from the actions drop down list b) Click the SraRT RECORD toolbar button, The START RECORDING dialog box opens with vuser_iaie in the Record into Action box. ©) Make sure that hetpi //1o the URL box and leave the RECORD THE APPLICATION STARTUP checked, then click OK. thost /serviets/com.mercurytours. servlet Welconeserviet is in 4) _ In the browser, sign in to Mercury Tours. i. Type jojo in the USER NAME field ji, ‘Type bean in the PASSWORD field. iii, Click the SI IN button, The FLIGHT FINDER page appears. Record into the showrtinerary Action. a) After the FLIGHT FINDER page appears. click the DOWN-ARROW button on the floating Record toolbar, and select Showrtinerary from the list. b) In the browser, perform the following steps: Exercises: Exercises 8 Actions i, Click the ITINERARY button near the top of the FLIGHT FINDER page. ‘The Tinerary page appears. This displays all the itineraries booked when logged in as joo. Click the FLIGHTS button on the left side of the ITINERARY page, undemeath the Mercury Tours logo. Record into the BookF Light Action. a) by After the FLIGHT FINDER page appears, select 8ookP Light from the list on the floating Record toolbar. In the browser, perform the following steps: i, Select 1 from the Passengers list. ii, Select “TLE from the DEPARTING FROM list. Select SYDNEY from the ARRIVING IN list, iv, Select FIRST CLASS from the SERVICE CLASS group. vy. Click the CONTINUE button. vi, The SELECT FLIGHT page appears, Vii, Click the ConTINUE button to accept the default flight selections. viii, The BOOK 4 FLIGHT page appears. ix, Type Joseph in the First NAME box under Passengers. x. Type wil1sane in the LAST NAME box under Passengers. xi. Select MASTERCARD from the CREDIT CARD TYPE list, xii, Type 1234567830 in the NUMBER box. xiii. Specify the expiration date as 10 and 2006 in the EXPIRATION section. xiv, Click the SECURE PURCHASE button. The FLIGHT CONFIRMATION page appears with a success message and a confirmation number, xv, Click the FLIGHTS bution on the left side of the ITINERARY page underneath the Mercury Tours logo. The FLIGHT FINDER page appear 8-19 v 8-20 Actions Record into the vuser-end Action. 2) After the FLIGHT FINDER page appears, select vuser_end from the list on the floating Record toolbar. >) Inthe browser, click the SIG! “OFF button to reset to the initial condition. Stop recording and save the script as: \Praining\uGen$ . 1Script ingForkeb\Ser spt s\mul| pleActions. ‘What is the reason for always ending the Action at the FLIGHT FINDER page? Part 2: Add Weighting In this exercise, you will use two weighting techniques so that one Action file iterates more frequently than the other. Random Weighting Save Mult iplea: on & RandonWweighting Set the Run properties to RANDOM. a) Make sure that you have the Randontleight ing script open. b) Open the RUN-TIME SETTINGS and click on the RUN Lo«Ic node. ©) Delete the Action i, Under the Run section. ji, Select Action and click the DELE E button. c) Right-click RUN, and select PROPERTIES from the pop-up menu, The RUN PROPERTIES dialog box opens. d) Select RANDOM from the RUN LOGIC list, and click OK. "[50%]" is added next to the showrt inerary and BookF?icht Actions underneath Run, Exercises Exercises Note: If you did not do step C then it will not show 50% for the Actions owrtinerary and Book# light Actions. 3, Set the Showrt ineeary Action properties to iterate 3 times for every iteration of the BookF Light a) Right-click showrtinerazy, and select PROPERTIES. b) Overwrite 50 with 75 in the RANDOM PERCENTS box, and click OK, ©) Right-click sookr1ighe, and select PROPERTIES from the pop-up menu. The ACTION PROPERTIES dialog box opens. d) Overwrite 50 with 25 in the RANDOM PERCENTS box, and click OK. Note: When using the Random run property, precisely correct weighting only occurs, when the script is iterated many times. It is statiscal you might get all of one Action or all of nother Action or exacily the right mix. But you can not predict, for every seript run it will be different mix of actions . How many iterations do you think you need to get th: run? correct weighting for the next Change the number of iterations for the Rien section to the number you used to answer the preceding question Enable the standard log in the RUN-TIME SETTINGS. Set the General Options: a) Select TOOLS > GENERAL OPTIONS to open the GENERAL OPTIONS dialog. box. b}__ Inthe REPLAY tab, check PROMPT FOR RESULTS DIRECTORY. ¢) Select VISUAL TES RESULTS in the AFTER REPLAY SHOW: list box. 4) Click OK to close the dialog box. Run the seript. Accept the default results directory or type a new name, 8-21 8-22 Actions Did shown: inerary run more times than ZookF1ight? How can you tell? Why did snowteinerary tun more times than Book? Light? 9. Close the Test RESULTS window. SEQUENTIAL WEIGHTING 1. Save Random#eight ing as SequentialWeighting. 2. Set the Run properties to Sequential, a) Select the RUN LOGIC screen in the RUN-TIME SETTINGS. b) Right-click RUN, and select PROPERTIES from the pop-up menu, Select SEQUENTIAL, from the RUN LOGIC list, and click OK 3, Insert a second showItinerary Action a) Right-click RUN again, and select INSERT ACTIONS from the pop-up menu. ‘The SELECT ACTIONS dialog box opens. b) Double-click showrtinerary inthe list. A second copy of the showrtinerary Action is added to the Ria list. 4, Insert a third showreinerary Action. a) Repeat the same procedure you used to add a second copy of the action. 5. Run the script. 6. Count the number of times show! inerary and BookF Light ran. a) In the Test Results. window click the PLUS sign next to the Iteration 1 icon EB andthe Heration 2 icon. b) Count the number of times that each action is listed. Did your count indicate that the sequential weighting worked correctly? Exercises Exercises 1 Actions, ee Close the Test RESULTS window and all the scripts when you have finished examining the results. Challenge Exercise: Configure Actions Based on Requirements Create a script to satisfy the below listed requirement. There is NO need to record any steps in the script. Just create the action sections to satisfy the requirement. Requirement: Emulate a purchasing agent logs-in in the moming, and logs out at night. During the day - = Creates 20 purchase orders — Modifies 5 purchase orders. — Searches for 10 orders Create a new script with three actions. Name the actions as a) PurchaseOrder b) ModifyOrder c) SearchOrder Create a block for ModifyOrder and SearchOrder actions, What will be the total number of iterations? Explai number? how you arrived at the eee Set the iterations for Run section based on the above answer. Set the property for Run as Random, Explain why the property setting for Run be set as Random? 8-23 8-24 Actions How will you derive the weighting percentage for the block and actions? Set the percentage based on your above answer and then click OK. ‘What is the prompt message from VuGer? How can you fix this? Fix the weighting percentage and click OK to close the RUN-TIME SETTING dialog Save the script as Act io} sand then Ron, Accept the default results directory or type a new name. Review the TEST RESULTS. Investigate the TEST RESULTS fo see how many times the actions were run? Close the Test RESULTS and the script once done. Exercises Actions Exercises 8-25 Actions 8-26 Exercises Introduction to Script View Introduction to Script View Objectives After completing this chapter, you will be able to: * Differentia ‘Tree and Script View. © Identify basic C code in VuGen including statements, variables, and functions, * Send customized output messages. * Apply debugging techniques in VuGen, 9-1 Introduction to Script View Tree View shows icons for the recorded user steps Each Tree View icon represents a i *C’ statement viewable in Script ix : I | View me Figure 9-1 ‘Tree View and Script View ‘TREE VIEW is icon-based SCRIPT VIEW is text-based. So far, we recorded our scripts in ‘TREE ViEW. In this chapter we will see how to work in SCRIPT VIEW. SCRIPT VIEW is a text-based view that lists the actions of the Vuser as API functions. When you replay a script, ANSI complaint C compiler is automatically called to compile and then run the script. Each step is recorded as a C function call, SCRIPT VIEW allows for direct editing of the C code to add additional functions, loops, verification and many other enhancements. From the VuGen main menu, select View — Scripr View, or click the SCRIPT VIEW toolbar button, The ScrieT VIEW displays the recorded user actions in C code. 9-2 ‘Tree View and Script View Introduction to Script View The Code Behind the Tree View Icon ‘web submit formy-FinaFight, = Brciong snapshot-t2ine, 1 tonnes dane EMDATA, Dp seatanncigne—————————?"Nama=useeName”, "Valuesjjo", ENDITEM, *Name=password”, "Valuesbean, ENDITEN, ‘ok time ae Figure 9-2 Code Behind the Icon Every icon step in the TREE VIEW represents ¢ statement in the SCRIPT VIEW. ‘The Code Behind the Tree View Icon 9-3 introduction to Script View Closer Look at Web Script in Script View slats BOER ew Pet ew mle Lor wow ap Sor Bi eawned hang) olds Sp State Eo) eee (ISS sus Emulates a mouse aliek ‘on the defined image [ Couses the current ‘Action to end and runs the next Action Figure 9-3 illustrates the structure of a basic seript in Script View. Notice the funetions and the opening and ending statements in the script. A VuGen expert can view a script and immediately know what Actions are performed, on which objects the Action to be performed, and the input or selection value to be used. a4 Closer Look at Web Soript in Soript View Introduction to Script View Why Use the Script View? ‘The ScRIPT VIEW cnables you to build more powerful and Flexible tests by allowing you to: © Execute conditional steps depending on dynamic information © Generate meaningful log messages. * Add logic using C functions and control flow statements. ‘Why Use the Script View? 9-5 Introduction ta Seript View Entering Steps or Function in the Script View 9-6 There are two ways to add new steps or functions to a script in the SCRIPT VIEW. * Use the INSERT — NEW STEP command, * Enter steps or funetions manually. Note: If you make changes 10 a script while in the ScriPr viEW, VuGen makes the corresponding changes in the TREE VIEW for that script the GUI environment of the Tree View provides an easy interface, allows you to do most of the tasks for script building. Sometimes, you need to program because aspects of the AUT or script require flexibility or the use of specialized functions. Entering Steps or Funetion in the Script View Introduction to Script View Using Insert + New Step Command Figure 9-4 Insert Now Step Selecting INSERT — NEW STEP from the menu opens the ADD STEP dialog and allows you to add functions. Types of functions: © General Functions + Protocol-Specific Functions © Sundard ANSI C Functions Using Insert > New Step Command 9-7 Introduction to Seript View Manually Entering Steps Steps or functions can also be added directly to the scripts within ScRiPT VIEW. ScRIPT VIEW provides the following features for editing convenience: * Word Completion * Show Function Syntax © Context-sensitive help 9-8 Manually Entering Steps Introduction to Script View Using ANSI C You can enhance your scripts by adding standard ANSI C functions. ANSI functions allow you to add: * Comments: * — Control flow statements © Conditional statements Note: Reference book for C Learning C By Kernighan and Ritehie. Using ANSI C 9-9 Introduction to Script View Example of ANSI C in VuGen deig- Wi eatin ee NO! alle? Figure 9-5 C Code in a Script The C example in this script uses streat to append a backslash to the directory name, fullpath. It then appends filename to fullpath 9-10 Example of ANSIC in VuGen Basic Basic C Syntax Introduction to Script View C Syntax Allexecutable statements in a script are terminated by a semicolon. Lines between /* */ are "comments" and VuGen won't try to execute them: use these lines to document your scripts. Also // these lines can be used to comment out ingle steps. Statements are case sensitive but white space (space and blank lines) are insensitive 9-11 Introduction to Script View Variables and Constants Variable A variable is a named entity which may represent different values at different times, Constant A constant is a named entity which always represents the same value. 9-12 Variables and Constants Introduction to Script View About Variables * All variables must be declared before the first executable line, Variables types include text string, integer, long, double etc Variable names may include only letters, numbers, and underscores and may not begin with a number Text values for string variables must be enclosed in double quotes. About Variables 913 Introduction to Seript View Variable Examples Integer int count = O; Example Long long Quantity = 1000000; Float float cost = 25.16; Char char letter = ‘a’; String char{] = “Programming In C°; Figure 9-6 Example of Variables 9-14 Variable Examples Introduction to Script View About Constants Constants are often used as function return codes to describe a result (e.g., ELOK, meaning "success”) If you are familiar with C, these constants are actually a C construct called MACRO, ‘They are evaluated by the C preprocessor. Constant Examples ‘lr_save_datetime ("Tomorrow is $B $d $¥", DATE_NOW + ONE_DAY, example “next"") ; - ~ Another example: if (event == GENERAL_ERROR) lr_set_transact ion_status (LR_PAIL) ; Lr_end_transaction("ti", LR_AUTO); #define LRD_ON_ERROR_CONTINUE | Example Note: There are NO equal to sign "=" and NO semi-colon ";” at the end of the function. About Constants 9-15 Introduction to Script View C Operators, Statements, and Functions Operators are symbols that represent specific actions. > (greater than) example >= (greater than or equal to) Note: "=" is an assignment operator. A statement is a line of instruction in a program, "Statement" is also used to refer to the keywords that designate the type of instruction to be performed. total = ni + nz; Example A function is a series of statements grouped tegether to perform a specifi task, printf function = printf (*Helle, world."); example Note: This an example of calling a function. Notice that the how the argument is enclosed within ( ) brackets, In this course we will not be discussing how to create your own functions. Note: "=" is an assignment operator 9-16 C Operators, Statements, and Functions Introduction to Script View C Operators Supported by VuGen - Examples Note: These are partial lists only - please see the LoadRunner Function Reference for more complete information, ARITHMETIC OPERATORS: 1 or ** (exponentiation) +44 (inevement by 1) (decrement by 1) LOGICAL OPERATORS: && (and) Hon RELATIONAL OPERATORS: > (greater than) >= (greater than or equal to) <{less than) Use = to assign a value to a variable. <= (less than or equal 1 Use = = to compare two values. = (equal to) != (not equal to) CONDITIONAL: ‘ 27: AB LIF (g=O) is tre. then ¢ becomes 17; if tis false then g becomes 18. ASSIGNMENT: C Operators Supported by VuGen - Examples H7 Introduction to Script View Commonly Used C Statements in VuGen 9-18 Control statements: Statements that affect the way other statements are executed are called control statements, These can be categorized as: = Conditional allow you to choose between two or more independent paths in a program depending on the result of some conditional test. Example: i and switch statements. = leration allow you to repeat an operation a specified number of times or as long as certain conditions hold. Example: for and wn Le statements. Commonly Used C Statements in VuGen Iniroduction to Script View The "if" Statement was Example 4 Ly_output_message (“statemen vi return (0); In the st example, the statements are executed if the condition is TRUE and if the condition is FALSE no action is taken and continues with the statement following the “wae @o example eput_message ("statement1”) ; 1r_output_message ("statement2”) } In this example too, the statements are executed if the condition is TRUE. In addi nif the condition is FALSE, statements following the ese statement are executed, The “if Statement 9-19 Introduction to Script View The ‘for’ Statement for (init; test; step) | statements Example} for( i= 0; i < strlen(HelloWorld), iv) £ bufferlil * Helloworid{il; 1r_output_message ("Building , buffer }; ‘The general form of the sor statement is shown above. The execution of the determined by three expressions: init, test, ané step. loop is The init expression indicates how the for loop should be initialized and usually sets the nitial value, For example, for( = 0; begins the loop by setting the variable + to 0. ‘The rest expression is a condition for determining whether the loop should continue, As long as the test expression is TRUE, the loop continues. For example, for (A= ly L < mp itty begins with 4 equal to 9 and continues as long.as : is less then n. Of course, the value of needs to be declared outside the for loop. ‘The step expression indicates how the value ofthe variable 4 changes from cycle to cycle. Most commonly, the increment is done using ++ operator, but it can also count backwards using the _ _ operator. Note: The expressions init, rest and step are separated by semicolons. 9-20 The ‘for’ Statement Introduction to Script View Commonly Used C Functions in VuGen C comes with many functions built-in, including the following general functions: String manipulation functions © Data type conversion functions * Output message funetions ‘Commonly Used © Functions in VuGen 9-21 Introduction to Script View C String Functions in VuGen serene Returns the pointer to the first occurrence of a character in a string, char *strchr ( const char *string, int ¢ ); Ghar vocring = "Hla Excelleney"s D) Shee Hiss: esti Hirt x = (Char “)stechr (string, *x")4 Leloubput_neasage "the frst oecusrence of xi to", first, stromp Compares string! and string? to determine the alphabetic order, int stremp ( const char *stringl, const char “stringZ }; ‘The Quick brown dog jumps over the lazy fox"; “the quick brown dog jumps over the lazy fox": char steingi(] char steing2[] exame result = stremp( stringl, string? ), evaluate the ‘result’ within a if statement, strlen Retuins the length (in bytes) of a string, size_¢ strlen ( const char “string ); jehar ‘string - “iia Excelleney the Duke of Exeter" Lr_output_nessage ("Sentence is tu chacacters example Long\a", sexten (string); return 0/1 Output: Sentence entered is 33 characters long strstr Returns the first occurrence of one string in another char *etrste { const char *stringl, const char *string2 ); char steingli] = “The quick brown fox") example if (strstr string, “brown” 9) i Ir_eutput_nessage ("brown found") 1 else 4 Le_output_messago("Brown NOT Found!"); 1 9-22 String Functions in VuGen Introduetion to Script View C Data Type Conversion Functions Converts string to an integer value atoi ( const char ‘string }; Example i = atoi(s); Lr_output_message ("Price $84", i); The result will be “Price $7” C Data Type Conversion Functions 9-23 Introduction to Script View VuGen Output Message Function ir_ovtput_message ‘Sends a message to the log file and Output window. int Lr_output_message (const char * format, exp2,.--expn}; Ir_output_message n output message example the above statement will give us: Actions.c (4): an output message So far we have seen how to manipulate strings and what functions to use. Without being able to see the outcome of the programming it will difficult to make sense of the results. To see the outcome of your programming in VuGen, use 1_output_message. ‘The message is sent to the LoadRunner Output windows and the Vuser log file. When a script is run in VuGen, the output file is output. ext. This output message is displayed in the REPLAY LOG with Action name and line number. Note: 1:_output_message works exactly sare as print £ function, 9-24 \VuGen Output Message Function Introduction to Script View Format Codes for Ir_output_message eput_message Function can display values in a variety of formats. In order to determine precisely how a value should be siplayed, the percent sign in the function is followed by a key letter that specifies the output format. The combination of the percent sign and the key letter is called format code. One or more format modifiers can appear between the first and last character of the format argument. Ly_ourput_message ("State is 3s. Area is 8a", state, totalarea); Beample In the above example: — %s stands for string output. = %d stands for integer output. Note: Make sure that the type of each argument is consistent with the corresponding format code. So in our example state should have declared as char and total area as int, Look at the example below: ple Lr_output_message ("State is fs. Area is Sd square feet", state totalarea); Output will be: | Action.c(9): State is CA. Area is 12 square feet Note: %e would give you single characters. Format Codes for Ir_output_message 9-25 Introduction to Script View Basic Script Debugging 9-26 Once you have created the script for your test, to debug it to ensure that it is free of errors. VuGen provides debug features to help you perform each of the following: * Find syntax errors * Add breakpoints * Execute single steps Basic Script Debugging Introduction to Script View Finding Syntax Errors ‘ation name = “The action containing the problamatic step or function, Tine number = ‘The Ena containing the ear. Figure 9-7 Replay Log Displays Syntax E VuGen will check the script for syntax errors whenever you click on the Compile button 33. Note hitting compile saves your script and there is NO undo. ‘The syntax errors are displayed in the REPLAY LOG. The following information will be listed for each error found: * Action Name * Line © Description To navigate directly to an error in your script, select the error und double-click on the error. Finding Syntax Errors 9-27 Introduction to Seript View BeBe ee [vet mate Lown me Jo Lage 1 gs test [Eee ored > Becton ere cenneen + tote | coe Lecrony | SE Berestiauiiaaen, “) veartnh oy brevet Sersietauiineth, siensne) “ Binaipom saad FO SASS LGHsIMg, //siguneat evens son evecare ee f i | | | i i | Tasee aL. (U)T wadeelaeed Taeaeivier “aEae™ wriserinit.e (4); synear error) found return’ exbect:ng as * " Rotion.c (6i)* undeclared identifier "Atte Daze! Gr) (Seounsnes and settines\\eprakash\ Lacs cetcinge\ eemp\\ronaneva\|\\somninad acnanase.c (5 \s} reper aa as Figure 9-8 Breakpoints Breakpoints pause execution at specific points in the script, enabling you to examine the effects of the script on your application at pre-determined points. To set a breakpoint, place the cursor on the desired line in the script and select INSERT > TOGGLE BREAKPOINT. The breakpoint symbol is displayed in the left margin of the seript To remove the breakpoint, place the cursor on the line with the breakpoint symbol, and click the BREAKPOINT button or press F9. Note: You can view and manage breakpoints using the BREAKPOINT MANAGER. From the BREAKPOINT MANAGER you can manipulate the breakpoints in your script. To open the BREAKPOINT MANAGER, select EDIT -> BREAKPOINTS. 9-28 Adding Breakpoints Introduction to Script View Executing Single Steps iL osemes 26 a) yily aD Debug toolbar a ee id x[secenn = “| acon aNDEE la vacrms re", one line at a time ran exorTe, ‘TE Resedeotog | £9 Conciente | () Genetontoy ho Repuay of Coadhwnner 1.0 for WIN2000; Wer Busta Run-Tine Settings tile. "C"yoecuncats ahd Set Ending action wiser_inic et a fae ead | Figure 9-9 Run Step By Step ‘The RUN STEP BY STEP Command runs the script one line at a time. This enables you to follow the script execution. To be able to use this feature make sure that you first invoke the Debug toolbar by selecting ViEW ~> TOOLBARS > DEBUG. This adds the Debug toolbar. Select VUSER = RUN STEP BY STEP, VuGen executes the first line of the script, Continue script execution by clicking the STEP button on the Debug toolbar until the seript run completes. Executing Single Steps 9-29 Introduction to Script View Summary * New steps can be added directly into the ScRIPr View via the step command. © C provides function seript in VuGen, s, statement, and operators that allow you to manipulate your * VuGen provides debug features for inserting breakpoints and stepping through scripts. 9-30 ‘Summary Introduction to Script View Exercises Objectiv In this lab, you will create a Web script to manipulate strings. v << v Exercises Answer the following questions to determine the steps that need to be added to the script in Part | exercise. wstrote ( const char ‘stringl, const char *string2 1; Explain the following and base your answers on the above statement; 1) Explain the purpose of the function 3 ee b) What does the star indicate in the above declaration? a) char tonestring = “Here is an easy way to create a string b) char anctherWay[] = “This works just as well" Explain what the above statements signify. What function could you use to calculate the string length? for (ie0; 1 < strlen(AnotherWay); itt) ( Ly_output_message ("$d: 80", i, Ani } Explain what will be the output of the above code. Found = strstr{QneString, "create"); 9-31 Introduction to Script View Explain the function of the above code, Ww if (ound) ( Lr_message ("IE found >48<", Found) ; 1 What will be the output of the above code? Explain how the above code will work, Note: Discuss the questions with your teacher before you proceed to add the code. Part 1: Add String Manipulation Code 1. Create a Web script and add code to do the following: a) Work in Scrip? View. i, Select ViEW > SCRIPT VIEW or click on the SCRIPT VIEW button on the VuGen main window. b) Declare a variable to compare strings. The type should be a pointer toa character. ¢) Declare a string anotherway as an array with the following value "This works just as well” d) Declare another string Onestring asa pointer to a character with the following vaiue and note the spaces "Here is an casy way to create @ tring r Note: Enter five empty spaces using the space bar. €) Write the code to print out the alphabet in the anothezway string with the iteration number. £) Write the code to search the string "Create" inside Onest ring Note: Notice the "><" characters in the print out message. 9-32 Exercises Exercises Introduction to Script View Save the script as ¢:\eaining\WuGeng . script ingForweb\seripts\stringManupulation Note: Please make sure that you ask the instructor of any doubts. Also use the solution script located under ¢:\Training\vuGen8. 1SeripcingForWeb\Solutions folder to understand the script better, 9-34 Introduction to Script View Exercises Advanced Scripting Techniques Advanced Scripting Techniques Objectives After completing this chapter, you will be able to: © Recognize general LoadRunner functions * Recognize protocol specific functions. * Add error handling and business logic. 10-1 Advanced Scripting Techniques Function Libraries for Load Testing 10-2 All of the ANSI C library is available in VuGen, Further more, Mercury hs c libraries of functions to create load tests. Note: To find out more on how a function operates in VuGen, move your cursor over the function and press FL. This will open the Function Reference with the details on the function, Function Libraries for Load Testing Advanced Scripting Techniques General LoadRunner Functions ‘The most common LoadRunner functions have a 1» prefix and can be used in scripts of any protocol. They can be categorized as follows: Message functions _message and 1r_output_message Send messages to the output, indicating an error or a warning. ‘Transaction Functions 1r_start_transaction and 1r_end_cransaction Add transactions and synchronization points to a script. For example, the 1r_start_transact ion function marks the beginning of a transaction, and the 1r_end_transaction function marks the end of a transaction Ruv ime Functions ar_think_cime and Le exit Parameter Functions lr_save_date time, lr_advance_param, 1r_eval_string, Ir_save string and 1r_get_attrib string General LoadRunner Functions 10-3 Advanced Scripting Techniques Ir_abort Aborts the execution of a script. It stops the execution of the Actions section, executes the voser_end section, and ends the execution: F_abort (0; ‘This function is useful when you need to manually abort a run as a result of a specific error condition, When you end a run using this function, the status is "Stopped." . 10-4 I_abor Advanced Scripting Techniques Ir_exit Exits from the script, action, or iteration: lr_exit (int continuation_option a specifies how the script the status of the script continues after the call as a result of calling to ir_exit Lr_exit Dy iE (status == LR_PATL) Example lr_error_message ("ftp login failed") ; Lr_emit (ER_EXIT_VUSER, LR_FAIL) return (0) Continuation Options LR_EXIT_VUSER. Exit without any condition, and go directly to end action LR_EXIT_ACTION_AND_CONTINUE | Stop current action, and go to the next action. LR_BXIT_MAIN_ITERATION_ ‘Stop current global script run iteration, AND_CONTINUE and go to the neat iteration. Table 10-1. Note: Refer to the Function Reference to leam about the other continuation option exit 10-5 Advanced Scripting Techniques Ir_save_string Assigns the specified nuli-terminated string toa parameter: The value to assign to ‘The name of the parameter the parameter ram_valy const char *param_name} ; This function is useful in correlating queries. BR le_save_string(777", “emp_id"hs ‘ing assigns 777 to a parameter eno_: . This parameter can then be used in any query 10-6 Ir save string Advanced Scripting Techniques Ir_save_date_time Saves the date and time into a parameter: r_save_date_timeiconst cha *format, int offset, const char *name); format of the offset from the name of the retrieved date/time current date and time, using the constants DATE_NOW, etc. parameter The 1r_save_davet ime function saves the current date and time, or the date and time with the specified offset into a parameter. You can use the format codes to build a format with any combination of strings and codes. For example, depending on the definitions in your computer's locale, "The current month is #2" would return The current month is JAN. "Sa&b%y" would return 29JAN97. For a detailed list of date/time format codes refer to the Function Reference documentation, ‘The parameter stores the information calculated by the 1y_save datetime function, You can use this parameter in the script to replace a hard coded date with the parameter created by the function which supplies the current date. Ir_save_date_time 10-7 Advanced Scripting Techniques Using Offset in Ir_save_date_time 10-8 ffset from the current date and time, using the constants: DATE_NOW, TIME_NOW, ONE_DAY, ONE_HOUR, ONE_MIN Lr_save_datetime{"Tomorrox is 8B 4d SY", DATE_NOW+ONE_DAY, “nextDate") WT of format of the date to offset from the name of the be retrieved in. current date and parameter time, Note: In the above eample for the offset argument, the function will first retrieve today"s date, then add a day. If today is January 7th, 2010, these lines will return the message: Tomorrow is January 08 2010 Using Offset in r_save_date_time ‘Advanced Scripting Techniques Ir_advance_param Advances to the next available value in the parameter data file: lr_advance_param (const char + param); UY Name of the parameter in quotes (no brackets) ( int xyiveis example //get the vuserID and store it in v col (ly eval_string("{Vuser!D}")); /iget the Iteration number and stor Lt in i isatoi (Lr_eval_string("{Iteration}")}; /feor the first iteration, x = VuserrD AE (isel) Kew, //For the second iterations onward, x = number of Vusers + 1 7/You need to medify this number according to the number of Vusers //you have in the scenario else x=6; For (y=liyex: yet) Lr_advance_param("NewParam") ; Ir_output_message(“This is vuser td, iteration 3d, with data ts",v,i yiz_eval_string("{NewParam}")) ; return 0; ) Ir_advance_param 10-9 Advanced Scripting Techniques Ir_eval_string Returns the value of the parameter as a string. Lr_eval_string("{parameter_nane|"); e¥—_ Name of parameter whose value needs to be retrieved To print this out as output message either use 1r_ovtput_message oF Lz_error message lr_error_message ("For &s ticket not purchased”, 1r_eval_string(*{parameter_name}")); to Note: string representation of the value of a specified variable. 10-10 Ir_eval_string Advanced Scripting Techniques Ir_get_attrib_string Assigns the specified null-terminated string to a parameter: 1r_get_attrib string (const char * argument); uys—~ Returns the string values associated with the argument You place the urgument name in the function's argument field and Lr_get_attrib_string retums the string values associated with that argument. 7/ Assign the new string to the Additional Attribute value for ‘URL’ Mr_save_string(Ir_get_attrib_string(°URL"),"Test_URL")); Jfthis makes the url call to the specified address example web_url("newtours.mercury.com", "URL=(Test_URL}", RecContentType=texy/htmnl”, "Referer=" "Smapshot=t1 inl", "Mode=HTML", LAST): | ‘The Command Line Parsing functions eliminate the need to parse the command line manually. Ir_get_attrib_string 10-11 ‘Advanced Scripting Techniques Protocol Specific Functions 10-12 Protocol-speci For example: functions are particular to the type of protocol that you are recording. * sob prefix for Web protocol The functions developed to emutate Internet communication between a browser or toolkit and a web server are called web functions. + cerx prefix for Citrix protocol * Led for Database funetions * tcp for FTP protocol * Les for windows sockets In addition to the general LR functions, VuGea also generates and inserts protocol-specific functions into the script while you record, Protocol Specific Functions Advanced Scripting Techniques Web_reg_save_param Saves dynamic data information to a parameter: Web_reg_save_param (const char *ParanName, 18, RB, ORD, Savelen, SaveOffset, LAST); The name of the List of atributes Marker that indicates the parameter to create end of the attribute list The web_ ‘am function is a service function used for correlating HTML statements in web scripts. Explanation of attri>ut LB: The left boundary of the parameter or the dynamic data. If you do not specify an LB value, it uses all of the characters from the beginning of the data as a boundary. Boundary parameters are case-sensitive. This attribute is required. RB: The right boundary of the parameter or the dynamic data. If you do not specify an RB value, it uses all of the characters until the end of the data as a boundary. Boundary parameters are case-sensitive. This attribute is required, ORD: Indicates the ordinal position or instance of the match, The default instance is 1. If you specify “All,” it saves the parameter values in an array. This attribute is optional. SaveLen: The length of a sub-string of the found value, from the specified offset, to save to the parameter. This attribute is optional. The default is -1, indicating to save to the end of the string, SaveOffset: The offset of a sub-string of the found value, to save to the parameter. The offset value must be non-negative. The default is 0. This attribute is optional Web_reg_save param 10-13 Advanced Scripting Techniques Web_reg_find Registers a search for a text string for the next Action function: Web_reg_find("Text=Welcome”, SaveCount, LAST) ye ‘The text string The number of marker that indi- to search for matches that were cates the end of the found attribute list The SaveCount stores the number of matches found for the web_reg_find function. This value is stored in the variable assigned. web_reg_find ("SaveCount=booked_cout “itinerary has been booked", LAST); web_submit_form("com.mercurytours. servlet .PurchaseServlet_2™ four Ani "Tex itanerary_reserved = atoi(Lr_eval_scring(" {booked_count}")) ; if (itinerary reserved > 0) 1 lx_output_message ("td itinerary/izineraries reserved.", itinerary reserved); else i Lr_error_message(*No reservations made.”); return 0; : Note: we>_reg_find is the function that gets inserted when you create checkpoints, 10-14 Web reg find Advanced Scripting Techniques Summary © General LoadRunner functions can be used in any protocol script. © General LoadRunner functions have a ir prefix. © Web protocol functions have web prefix. ‘Summary 10-15 Advanced Sctipting Techniques Exercises Objective: In this lab, you will add code to enhance the output log according to the requirement specified. Part 1: Enhance a Recorded Script 1. Create a new script against Mercury Tours. 2. Record the user steps for log in and then jog out. Login as "jojo" and "bean", 3. Stop recording and save the script as Eohancedseript under e:\Training\WuGend.1 iptingForveb\seripts. 4, Add atext to verify that the login was successful 5. Parameterize the username and password fields. Use the following data only: USERNAME ~~ [ passworp jeje bean jackie chan susan lawless jet Ti - 6, Add an image checkpoint for the Flight Finder image on the FLIGHT FINDER page. HINT: Right-clicking on the Flight Finder image in the browser and selecting properties will give you the image name, NF {iow sill you enable the image check? Eaplain why you nae this setting for image check and not the text check added earlier? 7. Save the seript. Part 2: Add Programming code to the Enhanced Sci 1. Open ennanceascript and save it as cocedss te 10-16 Exercises

You might also like