教训1:建立一个Vuser Script
To generate a load on your system, you first build a Vuser script that you can run to emulate real user behavior. You use VuGen to create and build Vuser scripts.
生成你的系统上的负载,你首先建立一个虚拟用户脚本可以运行模拟真实的用户行为。你使用VuGen创建Vuser脚本。
In this lesson you will cover the following topics:
在本课中,您将讨论以下主题:
•Introducing VuGen - the Virtual User Generator
•介绍VuGen的虚拟用户生成器
•Creating a Blank Vuser Script
•创造Blank Vuser Script
•Recording a Vuser script
•记录一个虚拟用户脚本
•Viewing the Vuser script
•查看Vuser的剧本
将打开的虚拟用户生成器
In a performance testing environment, LoadRunner replaces human users with virtual users, also known as Vusers. Vusers generate a load on a system by emulating actions of typical users - in a repeatable and predictable manner.
在性能测试环境,LoadRunner代替人类用户与虚拟用户,也被称为虚拟。用户通过模拟典型用户的行为在一个可重复的和可预测的方式产生一个系统负载。
You use VuGen (LoadRunner's Virtual User Generator) to create Vuser scripts. VuGen works on a record-and-playback principle. As you walk through a business process on your application, VuGen records your actions and transforms these actions into steps in a Vuser script. These Vuser scripts form the foundation of your load tests.
你使用VuGen(LoadRunner的虚拟用户生成器)创建虚拟用户脚本。打开工作记录和回放的原理。当你走在你的应用程序的业务流程,VuGen记录你的行动和改变这些行为在虚拟用户脚本的步骤。这些虚拟用户脚本的形式负载测试的基础。
创造一个Blank Vuser Script
To develop a Vuser script, you first open VuGen and create a blank script. Thereafter, you can enhance the blank script by recording events and adding manual enhancements to the script.
开发一个虚拟用户脚本,你第一次打开VuGen和创建一个空白的脚本。此后,您可以通过记录事件和添加脚本的手动增强来增强空白脚本。
In this section, you will open VuGen and create a blank Vuser script that is based on the Web - HTTP/HTML protocol.
在这一部分中,你将打开VuGen并创建一个空白的虚拟用户脚本是基于Web的HTTP / HTML协议。
To create a blank Vuser script:
创建一个空白的虚拟用户脚本:
1.On the LoadRunner machine, double-click the Virtual User Generator shortcut icon on the desktop to open VuGen.
1。在LoadRunner的机器,双击虚拟用户生成器的快捷图标放在桌面上打开打开。
2.Click File > New Script and Solution or click the Add New Script button on the VuGen toolbar. The Create a New Script dialog box opens.
2,点击文件>新的脚本和溶液或点击添加的工具栏按钮打开新的脚本。创建一个新的脚本对话框打开。
3.Make sure the Category in the left pane is Single Protocol. VuGen displays a list of the protocols that are available for a single-protocol script.
3、确保左侧窗格中的类别是单一协议。打开显示一个列表,可用于单协议脚本的协议。
4.From the list of available protocols, select Web - HTTP/HTML and then click Create.
4、从可用的协议列表中,选择Web http / HTML,然后单击“创建”。
VuGen creates a blank Vuser script and displays the script in the VuGen Editor.
打开创建一个空白的虚拟用户脚本在VuGen编辑器显示脚本。
记录一个虚拟用户脚本
The next step in developing the Vuser script is to record the actions performed by a real user. In the previous section, you created an empty Web - HTTP/HTML Vuser script. Now you can begin to record actions directly into the script. In this section, you will track the actions that a travel agent performs to reserve a flight from Denver to Los Angeles, and check the flight itinerary.
在开发虚拟用户脚本的下一步是记录一个真实的用户执行的操作。在上一节中,您创建了一个空的web HTTP/HTML虚拟用户脚本。现在您可以开始将操作直接记录到脚本中了。在本节中,您将跟踪旅行代理商为预订从丹佛到洛杉矶的航班,并检查航班行程。
Note: To enable VuGen to record the actions that you perform in the Web Tours application, click Record > Recording Options. In the Recording Options dialog box, select General > Script, and then under Scripting Options, make sure that the Track processes created as COM local servers check box is cleared.
注:为了使VuGen记录你在网络旅游应用执行的操作,点击选项>录音记录。在“录制选项”对话框中,选择“常规>脚本”,然后在“脚本选项”下,确保清除了创建为“COM本地服务器”的跟踪进程复选框。
To record the Vuser script:
记录虚拟用户脚本:
1.Start recording on the HP Web Tours web site.
1、在HP Web旅游网站上开始录制。
a.Click Record > Record or click the Record button on the VuGen toolbar. The Start Recording dialog box opens.
A.点击记录>记录或点击工具栏上的按钮打开记录。“开始录制”对话框打开。
b.In the Record into action box, select Action.
B.在“记录到动作”框中,选择动作。
c.From the Record list, select Web Browser.
C.从记录列表中选择Web浏览器。
d.In the Application box, make sure that Microsoft Internet Explorer appears.
D.在应用程序框中,确保微软Internet Explorer出现。
e.In the URL address box, type http://localhost:1080/WebTours.
E.在URL地址”框中,键入HTTP:/ / 1080 / webtours本地。
f.Click Start Recording. A new web browser opens and displays the HP Web Tours home page.
F.点击开始录音。一个新的Web浏览器打开并显示HP Web旅游主页。
Note: If there is an error opening HP Web Tours, make sure that the Web Tours Server is running. For details, see Using the HP Web Tours Sample Application.
注意:如果打开HP Web旅行出错,请确保Web漫游服务器正在运行。有关详细信息,请参阅使用HP Web旅行样例应用程序。
VuGen's floating Recording toolbar opens.
打开记录的浮动工具栏打开。
2.Log on to HP Web Tours.
2、登录到HP Web旅游。
a.Type in the following information:
输入下列信息:
- User name: jojo
用户名称:JOJO
- Password: bean
-密码:bean
b.On the left pane, click Login. HP Web Tours welcomes you to the application.
在左侧窗格中,单击登录。HP Web旅游欢迎您的应用程序。
3.Enter the flight details.
3、输入航班详细信息。
a.Click Flights. The Find Flight page opens.
点击航班。查找飞行页面打开。
b.From Departure City, select Denver (default).
从出发城市,选择丹佛(默认)。
c.Departure Date: Keep the default date.
C.离开日期:保持默认日期。
d.From Arrival City, select Los Angeles.
从抵达城市,选择洛杉矶。
e.Return Date: Keep the default date.
E.返回日期:保持默认日期。
f.From Seating Preference, select Aisle.
从座位偏好,选择过道。
g.Keep the rest of the default settings and click Continue. The Find Flight page opens.
保留其余的默认设置,然后单击继续。查找飞行页面打开。
4.Select a flight.
4、选择航班。
Click Continue to accept the default flight selections. The Payment Details page opens.
单击“继续”接受默认航班选择。付款详细信息页打开。
5.Enter payment information and book the flight.
5、输入付款信息并预订航班。
a.In the Credit Card box, enter 12345678.
在信用卡框中,输入12345678。
b.In the Exp Date box, enter 06/19.
在“输入日期”框中,输入06 / 19。
c.Click Continue. The Invoice page opens, displaying your invoice.
单击“继续”。发票页打开,显示您的发票。
6.In the left pane, click Itinerary. The Itinerary page opens.
6、在左侧窗格中单击“行程”。行程页面打开。
7.In the left pane, click Sign Off.
7、在左侧面板中单击“关闭”。
8.Close the browser, and then click the Stop Recording button on the VuGen floating toolbar to stop the recording process.
8,关闭浏览器,然后单击“停止录制”按钮,在打开的浮动工具栏停止记录过程。
VuGen generates the required code and inserts the code into the Vuser script.
脚本生成器生成所需的代码并将代码插入到虚拟用户脚本。
If the Design Studio opens, click Close to close the Design Studio.
如果设计工作室打开,单击关闭来关闭设计工作室。
9.Save the Vuser script.a.Select File > Save Script As.
9。保存虚拟用户script.
a.select文件>保存脚本。
b.Navigate to <LoadRunner Installation>\tutorial, create a new folder named Scripts, and then navigate to the new Scripts folder.
B.浏览<< LoadRunner安装> \教程,创建一个新文件夹命名为脚本,然后导航到新的脚本文件夹。
c.In the File name box, type basic_tutorial.
C.在“文件名”框中,键入basic_tutorial。
d.Click Save. VuGen saves the script and displays the script name in the VuGen title bar.
d.单击保存。打开保存脚本并显示在标题栏中打开脚本名称。
看Vuser的脚本
You have now recorded the actions of a travel agent logging in, booking a flight, checking the itinerary, and logging off. VuGen recorded your steps from the moment you clicked the Start Recording button to the moment you clicked the Stop Recording button.
现在,您已经记录了旅行代理登录、预订航班、检查行程和注销的操作。VuGen记录你的步当你点击开始记录按钮,当你点击停止录制按钮。
You can now use VuGen to view the script. VuGen lets you see the Vuser script in a number of formats:
现在你可以使用VuGen查看脚本。打开让你在一些格式看到虚拟用户脚本:
•The Solution Explorer gives you structured access to the various parts of a Vuser script, as well as to a number of files that are associated with the Vuser script.
•解决方案资源管理器给你结构化访问一个虚拟用户脚本的各个部分,以及大量的与Vuser相关的脚本文件。
•The Step Navigator displays an icon-based view of the script that lists the actions of the Vuser as steps. For each action you performed during recording, VuGen generated a corresponding step in the Step Navigator.
•步导航仪显示的图标的脚本,列出Vuser的行动步骤的观点。你在记录的每一个动作,VuGen中产生相应的步步导航仪。
The Step Navigator displays a snapshot icon to indicate that a specific step contains a snapshot.
步骤导航器显示快照图标,以指示特定步骤包含快照。
To view the script in the Step Navigator, select View > Step Navigator, or click the Step Navigator button on the VuGen toolbar. Double-click any step in the Step Navigator to display the corresponding function in the Editor.
在Navigator视图的步骤的脚本,选择视图>步导航仪,或单击工具栏上的导航按钮打开一步。双击步骤导航器中的任何步骤以在编辑器中显示相应的函数。
•The VuGen Editor displays a text-based view of the script. In the Editor, the actions of the Vuser are listed as API functions. In the Editor, VuGen uses color-coding to show the functions and their argument values in the script. You can type C or LoadRunner API functions, as well as control flow statements, directly into the script.
•的VuGen编辑器显示脚本的文本观。在编辑器中,对虚拟用户的行为列为API函数。在编辑器中,VuGen使用颜色代码的脚本显示和参数值的函数。你可以C型或LoadRunner API函数,以及控制流语句,直接进入脚本。