LoadRunner执行自动化以及报告自动化的方法
There are three major articles KB articles on Automating LR:
1. Command line arguments for the LoadRunner Controller – Previously Mercury KB 13352
2. How to execute Analysis with a .lrr or .lra file from DOS - Previously Mercury KB 9241
3. How to create an HTML report without user intervention using Analysis - Previously Mercury KB 38562
4. There is also an API by which you can set some of the Runtime settings, but not launch tests.
1. Command line arguments for the LoadRunner Controller
The basic syntax is:
Wlrun.exe –TestPath C:\Temp\Scenario1.lrs –ResultLocation C:\Temp –ResultCleanName Res1 –Run
Note:
1. Make sure that the Controller is shut down before starting the scheduled task.
2. When running the Controller via the Command Line, Controller will be shut down automatically after the scenario ends.
Command line parameters are parameters that the Controller receives when it is invoked. They are used to instruct the Controller on how to behave. When invoked, the Controller checks all the received parameters and sets its startup environment accordingly. If no parameters are passed, the Controller uses its default settings.
By passing parameters in the command line, you may set the Controller and the scenario’s settings without the need to manually define them in the Controller UI. For example, you can instruct the Controller whether to connect to TestDirector on startup by using the ConnectToTD parameter, save the results to a directory other than that defined in the scenario by using the ResultName parameter, or invoke Analysis upon scenario termination with the InvokeAnalysis parameter.
The most common use of the Command Line is done by TestDirector. TestDirector includes a special program called "Test Run Scheduler," which was designed for scheduling the Controller to run scenarios at a specific date and time. It automatically invokes the Controller and runs scenarios. Results are saved in the TestDirector database. To do that, TestDirector must set the scenario’s environment by supplying the Controller with specific parameters.
Predefined rules:
- When one or more parameters are not passed, the Controller uses its default settings.
- Results will always be overwritten.
- The Controller will automatically terminate upon scenario termination and the results will be then collated.
- The Controller’s settings are loaded from wlrun5.ini located in the Windows directory.
- The following parameters are supported on all Windows 9x and Windows NT platforms.
Switches for LoadRunner/TestDirector integration:
- ConnectToTD - Should the Controller connect to TestDirector on startup (0/1 or ON/OFF).
- TDServer - TestDirector server name. Must be a computer name with TestDirector installed.
- TDDB - Database name. For example, "lrun."
- UserName - User name.
- Password - Password for the user name.
- TestPath - Path to scenario in the TestDirector database. For example, "[TD]\Subject\LoadRunner\Scenario1." If the path includes white spaces, use quotation marks.
- TestId – Test ID (for TestDirector only).
- ResultCleanName - For use with ResultCycle only, for example, "Res1."
- ResultCycle - TestDirector cycle, for example, "LR_60_SP1_247." To define the results path in TestDirector, the Controller must be provided with two parameters: ResultCycle and ResultCleanName.
Run-Time Switches:
- Run – Runs scenario, dumps all output messages into res_dir\output.txt and closes the Controller.
- InvokeAnalysis - InvokeAnalysis will set a flag in the Controller, which will invoke Analysis upon scenario termination (If not used, the scenario value will be taken).
Results Switches (for File System):
- ResultName - Full results path, for example, "C:\Temp\Res_01."
- ResultCleanName - Results name, for example, "Res_01."
- ResultLocation - Results directory. For example, "C:\Temp".
- Note:
- If the scenario does not specify a results directory and one of the above parameters was not passed, the scenario will not run!
- The results will always be automatically collated upon scenario termination.
- The results will always be automatically overwritten.
Command Line Syntax examples:
· Wlrun.exe –TestPath C:\Temp\Scenario1.lrs -ResultName C:\Temp\Res1 –Run –InvokeAnalysis
· Wlrun.exe –TestPath C:\Temp\Scenario1.lrs –ResultLocation C:\Temp –ResultCleanName Res1 –Run
· Wlrun.exe –ConnectToTD on –TDServer localhost –TDDB lrun –UserName yaniv18 –Passwordb#12GcSA –TestPath "[TD]\Subject\Trash for LR/TD Integration\Scenario1" –Run
· Wlrun.exe –ConnectToTD 1 –TestPath "[TD]\Subject\Trash for LR/TD Integration\Scenario1"
Related articles that may be of interests:
Problem ID 2782 - How to run a scenario at a specific (absolute) time
Problem ID 15717 - Wlrun.exe does not close when executing a scenario via command line option
Problem ID 9277 - How can we read in string/text content from command line in controller and use them in a script
Problem ID 22476 - Running LR from Command line does not collate results from remote machine
Problem ID 3894 - How to pass command line arguments to a WinRunner script
Problem ID 45309- How to execute a VuGen script from DOS
Problem ID 9241- How to execute Analysis with a .lrr or .lra file from DOS
Attachment : CPT13351.zip
----------------------------------------------------------------------------
You can also run Vugen from DOS
How to execute a VuGen script from DOS (previously http://kb-web.mercury.com/KBA/KBAview.asp?Conceptid=45309&Product=LR)
Solution: Executing a VuGen script from the command line
Here is the command line that you need to execute to run a VuGen script from the command prompt:
<LoadRunner>\bin\mmdrv.exe -usr <path to usr file>
Note:
In order to get all the other options that go with the command, run mmdrv.exe from the command prompt without any options.
--------------------------------------------------------------------------
Setting the Granularity Programatically
http://kb-web.mercury.com/KBA/KBAview.asp?Conceptid=11762&Product=LR
Problem Description: Can the default granularity for new graphs be set?
Is there a way to set the Analysis Tool to open new graphs with a custom granularity? For example, LoadRunner may open all graphs with the granularity set to 300 seconds. Is there away to set it to 10 seconds?
Solution: Create a user-defined template for the Analysis tool.
There is no way to set the same granularity to all graphs in Analysis once the result set has been processed. However as a work-around, create and use a user-defined template.
1. Open a result set in Analysis.
2. Open up all sets of graphs.
3. In each graph, set the granularity you want (i.e., 10 seconds).
4. Choose Tools -> Templates -> Save as template.
5. Clear the "Use automatic granularity" checkbox.
6. Select the "Automatically set to new result" checkbox.
As a result, each new result set will be opened with the above graphs and granularity desired, with the exception of the Throughput graph. For the Throughput graph, the minimum granularity is 5 seconds by the product design. The reason for it is to avoid too much overhead. If you would like to set it to a lower value (not recommended due to overhead), here's what you can do (before you run your scenario):
Note:
Please back up your files before any modification.
1. Open the default.cfg file of the script using a word editor. In the [WEB] section add one more line:
[WEB]
WebGraphsAggregation=n
where n is the number of seconds for graph aggregation.
2. Open throughput.def in the <LoadRunner>bin\dat directory using a word editor. In the [Granularity] section, comment out "BaseGranularityUIName" by putting a semicolon at the beginning of the line:
Example:
[Granularity]
Dimension=Scenario Elapsed Time
;BaseGranularityUIName=Throughput
3 Open Result0_Graph2.def in <LoadRunner>\AnalysisTemplates\DefaultTemplate1 using a word editor. In the [Granularity] section, comment out "BaseGranularityUIName" by putting a semicolon at the beginning of the line:
Example:
[Granularity]
Dimension=Scenario Elapsed Time
;BaseGranularityUIName=Throughput
4. Save the changes and rerun your scenario.
----------------------------------------------------------------------------
2. : How to execute Analysis with a .lrr or .lra file from DOS
http://kb-web.mercury.com/KBA/KBAview.asp?Conceptid=9241&Product=LR
How to execute the Analysis from command line with a .lra or .lrr file as a parameter.
Solution: Executing Analysis from the command line
Here is the command line that you need to execute to run Analysis from the command prompt:
<LoadRunner>\bin\analysisui.exe -RESULTPATH <path to lrr/.lra file>
You can as use the flag –TEMPLATENAME templatename to specify the template you want to use.
NOTE: templatename should only contain the name of the template to be used. The full path is hard coded in a configuration file.
----------------------------------------------------------------------------
3. Problem Description: How to create an HTML report without user intervention using Analysis
Solution: Use an Analysis template
http://kb-web.mercury.com/KBA/KBAview.asp?Conceptid=38562&Product=LR
a. Open an Analysis session with all the graphs that you are interested in and save this as a template. When saving this template, make sure that the option "Automatically apply this template to a new session" is checked. Also select the option "Generate the following Automatic HTML Report" and specify the location for where you want to save your reports.
Note:
Make sure that there are no folders with the name Report and no files called Report.html at that location.
b. Close Analysis and invoke it through the command line in a new lrr file using the direction from Problem ID 9241 - How to execute Analysis with a .lrr or .lra file from DOS.
c. This will first analyse the result and create a session file. Then, Analysis will apply the template and create an HTML report at the location selected in the template.
----------------------------------------------------------------------------
4. The Mercury Controller API
http://kb-web.mercury.com/KBA/KBAview.asp?Conceptid=15334&Product=LR
Solution: LoadRunner Automation libraries / Controller's API
To find out more about Controller API/Automation Library
1. Bring up VuGen
2. Go to Help -> Contents and Index
3. Expand Books Online
4. Refer to LoadRunner Automation References
______________________________________________
Problem Description: How to set the Run-Time Settings programmatically instead of using the Run-Time Settings dialog box
Is it possible to programmatically set the Run-Time Settings through VuGen scripts instead of using the Run-Time Settings dialog box?
Solution: The Run-Time Settings can be set using the LoadRunner API
http://kb-web.mercury.com/KBA/KBAview.asp?Conceptid=37690&Product=LR
Generic functions:
|
lr_set_debug_message |
Run-Time Settings -> Log |
|
lr_think_time |
Run-Time Settings -> Think time |
|
lr_continue_on_error |
Run-Time Settings -> Miscellaneous -> Error handling -> Continue on error |
Web Vuser:
|
web_set_timeout |
Run-Time Settings -> Preferences -> Option -> Connect/Receive/Step Download timeout |
|
web_enable_keep_alive |
Run-Time Settings -> Preferences -> Option -> Keep-Alive HTTP connection |
|
web_set_max_retries |
Run-Time Settings -> Miscellaneous -> Error handling -> Run-Time Settings -> Preferences -> Option -> Max number of <META refresh> to the same page |
Citrix Vuser:
|
ctrx_set_waiting_time |
Run-Time Settings -> Timing -> Connect timeout |
Some additional Run-Time Settings:
|
lr_abort |
Aborts Vuser script execution. |
|
lr_disable_ip_spoofing |
Disables IP Spoofing. |
|
lr_enable_ip_spoofing |
Enables IP Spoofing. |
|
lr_exit |
Exits from the script, action, or iteration. |
|
lr_rendezvous |
Sets a rendezvous point in a Vuser script. |
|
lr_rendezvous_ex |
Sets a rendezvous point in a Vuser script. |
Refer to the Function Reference for details about all these functions.
LoadRunner执行自动化以及报告自动化的方法的更多相关文章
- Python自定义钉钉机器人发送自动化结果报告
环境python3.5+jenkins # coding:utf-8 import urllib.request import json import sys import time import r ...
- Selenium2+python自动化65-js定位几种方法总结
Selenium2+python自动化65-js定位几种方法总结 前言 本篇总结了几种js常用的定位元素方法,并用js点击按钮,对input输入框输入文本 一.以下总结了5种js定位的方法 除了i ...
- 接口自动化与UI自动化两者的可行性
1.首先接口测试是跳过前端界面对服务端的测试,UI测试是对前端界面的测试,从分层测试的角度考虑,两者不应该是可以互相取代的关系. 2.从公司开展自动化的的角度考虑,可以重点关注这个项目开展接口自动 ...
- java 执行 jar 包中的 main 方法
java 执行 jar 包中的 main 方法 通过 OneJar 或 Maven 打包后 jar 文件,用命令: java -jar ****.jar执行后总是运行指定的主方法,如果 jar 中有多 ...
- MySQL命令执行sql文件的两种方法
MySQL命令执行sql文件的两种方法 摘要:和其他数据库一样,MySQL也提供了命令执行sql脚本文件,方便地进行数据库.表以及数据等各种操作.下面笔者讲解MySQL执行sql文件命令的两种方法,希 ...
- 执行shell脚本的几种方法及区别
执行shell脚本的几种方法及区别 http://blog.csdn.net/lanxinju/article/details/6032368 (认真看) 注意:如果涉及到脚本之间的调用一定要用 . ...
- 在WebBrowser中执行javascript脚本的几种方法整理(execScript/InvokeScript/NavigateScript) 附完整源码
[实例简介] 涵盖了几种常用的 webBrowser执行javascript的方法,详见示例截图以及代码 [实例截图] [核心代码] execScript方式: 1 2 3 4 5 6 7 8 9 1 ...
- SqlBulkCopy批量插入数据时,不执行触发器和约束的解决方法
原文:SqlBulkCopy批量插入数据时,不执行触发器和约束的解决方法 在new SqlBulkCopy对象的时候,设置一下SqlBulkCopyOptions选项即可,按位或运算 SqlBulkC ...
- SQL 2005 中查询或执行另外的数据库操作的方法
原文:SQL 2005 中查询或执行另外的数据库操作的方法 摘要: 如果,你想在一台数据库服务器上,查询另一个台数据服务器的数据该如何做呢?如果,你想在同一台数据服务器上,在不同的数据库之间查询数据, ...
随机推荐
- xmlWriter 以UTF-8格式写xml问题
dom4j中的XMLWriter提供以下几种构造方法: XMLWriter() XMLWriter(OutputFormat format) XMLWriter(OutputStream out) X ...
- UVa 1626 (输出方案) Brackets sequence
正规括号序列定义为: 空序列是正规括号序列 如果S是正规括号序列,那么[S]和(S)也是正规括号序列 如果A和B都是正规括号序列,则AB也是正规括号序列 输入一个括号序列,添加尽量少的括号使之成为正规 ...
- UVa 11137 (完全背包方案数) Ingenuous Cubrency
题意:用13.23……k3这些数加起来组成n,输出总方案数 d(i, j)表示前i个数构成j的方案数则有 d(i, j) = d(i-1, j) + d(i, j - i3) 可以像01背包那样用滚动 ...
- HDU 3068 (Manacher) 最长回文
求一个字符串的最长子串,Manacher算法是一种O(n)的算法,很给力! s2[0] = '$',是避免在循环中对数组越界的检查. 老大的代码: http://www.cnblogs.com/Big ...
- 菜鸟学习笔记3——jQuery 选择器
jQuery 元素选择器 jQuery 使用 CSS 选择器来选取 HTML 元素. $("p") 选取 <p> 元素. $("p.intro") ...
- (四)Logistic Regression
1 线性回归 回归就是对已知公式的未知参数进行估计.线性回归就是对于多维空间中的样本点,用特征的线性组合去拟合空间中点的分布和轨迹,比如已知公式是y=a∗x+b,未知参数是a和b,利用多真实的(x,y ...
- linux上改变mysql数据文件的位置
用软连接改变了/var/lib/mysql的位置,并设置好mysql.mysql的权限,但是发现还是不能启动. 发现/var/log/mysqld.log 150308 16:16:02 [Warni ...
- 【javascript】js 判断微信浏览器
上周接到个需求,需求是这样的:用户扫一扫二维码会产生一个链接,该链接会向后端发送个请求,返回一个 apk 的下载地址,用户点击下载按钮可以下载此 apk.然后就发生了问题,经过测试,发现用微信扫一扫打 ...
- 输出流 写文件 文本 换行nextLine
FileOutputStream fos = new FileOutputStream( "c:\\test.txt "); String nextLin ...
- Ubuntu 安装
最近又有工作需要,又需要在虚拟机上工作了.记得上次使用Ubuntu的时候还是7,8年前呢 用的是vmware 7 ,buntu的版本记不清了.时隔多年又捡起来了,记忆还停留在过去,于是被折腾惨了. 1 ...