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执行自动化以及报告自动化的方法的更多相关文章

  1. Python自定义钉钉机器人发送自动化结果报告

    环境python3.5+jenkins # coding:utf-8 import urllib.request import json import sys import time import r ...

  2. Selenium2+python自动化65-js定位几种方法总结

    Selenium2+python自动化65-js定位几种方法总结   前言 本篇总结了几种js常用的定位元素方法,并用js点击按钮,对input输入框输入文本 一.以下总结了5种js定位的方法 除了i ...

  3. 接口自动化与UI自动化两者的可行性

    1.首先接口测试是跳过前端界面对服务端的测试,UI测试是对前端界面的测试,从分层测试的角度考虑,两者不应该是可以互相取代的关系.   2.从公司开展自动化的的角度考虑,可以重点关注这个项目开展接口自动 ...

  4. java 执行 jar 包中的 main 方法

    java 执行 jar 包中的 main 方法 通过 OneJar 或 Maven 打包后 jar 文件,用命令: java -jar ****.jar执行后总是运行指定的主方法,如果 jar 中有多 ...

  5. MySQL命令执行sql文件的两种方法

    MySQL命令执行sql文件的两种方法 摘要:和其他数据库一样,MySQL也提供了命令执行sql脚本文件,方便地进行数据库.表以及数据等各种操作.下面笔者讲解MySQL执行sql文件命令的两种方法,希 ...

  6. 执行shell脚本的几种方法及区别

    执行shell脚本的几种方法及区别 http://blog.csdn.net/lanxinju/article/details/6032368 (认真看) 注意:如果涉及到脚本之间的调用一定要用 . ...

  7. 在WebBrowser中执行javascript脚本的几种方法整理(execScript/InvokeScript/NavigateScript) 附完整源码

    [实例简介] 涵盖了几种常用的 webBrowser执行javascript的方法,详见示例截图以及代码 [实例截图] [核心代码] execScript方式: 1 2 3 4 5 6 7 8 9 1 ...

  8. SqlBulkCopy批量插入数据时,不执行触发器和约束的解决方法

    原文:SqlBulkCopy批量插入数据时,不执行触发器和约束的解决方法 在new SqlBulkCopy对象的时候,设置一下SqlBulkCopyOptions选项即可,按位或运算 SqlBulkC ...

  9. SQL 2005 中查询或执行另外的数据库操作的方法

    原文:SQL 2005 中查询或执行另外的数据库操作的方法 摘要: 如果,你想在一台数据库服务器上,查询另一个台数据服务器的数据该如何做呢?如果,你想在同一台数据服务器上,在不同的数据库之间查询数据, ...

随机推荐

  1. Spring 实践 -AOP

    Spring 实践 标签: Java与设计模式 AOP引介 AOP(Aspect Oriented Programing)面向切面编程采用横向抽取机制,以取代传统的纵向继承体系的重复性代码(如性能监控 ...

  2. 多态and接口

    一.多态 1.什么是多态? 解析:不同的对象对于同一个操作,做出的响应不同 具有表现多种形态的能力的特征 2.使用多态的优点 解析:为了实现统一调用 一个小例子:<父类类型作为参数> 父类 ...

  3. Android 最火的快速开发框架XUtils

    参考:http://www.oschina.net/p/xutils 项目git地址https://github.com/wyouflf/xUtils 目录(?)[-] 最近搜了一些框架供初学者学习比 ...

  4. UVa 10391 (水题 STL) Compound Words

    今天下午略感无聊啊,切点水题打发打发时间,=_=|| 把所有字符串插入到一个set中去,然后对于每个字符串S,枚举所有可能的拆分组合S = A + B,看看A和B是否都在set中,是的话说明S就是一个 ...

  5. UVa (BFS) The Monocycle

    题目不光要求要到达终点而且要求所走的步数为5的倍数,每个时刻有三个选择,前进,左转弯,右转弯. 所以在vis数组中新增加两个维度即可,vis[x][y][dir][color]表示在(x, y)格子方 ...

  6. Odoo 的库存管理与OpenERP之前的版本有了很大的不同,解读Odoo新的WMS模块中的新特性

    原文来自:http://shine-it.net/index.php/topic,16409.0.html 库存移动(Stock Move)新玩法Odoo的库存移动不仅仅是存货在两个“存货地点”之间的 ...

  7. [Swift系列]002-基础语法

    基础语法就那老几样,很快可以说完 [常量.变量] 1.变量用 var,系统自动去判断类型,但变量再次赋值需保持数据类型一致 var  a=50 相信用过js/java/C#的,对这个var都不陌生 使 ...

  8. web项目路径问题

    路径    相对路径        URL中第一个字符不为“/”        request.getRequestDispatcher("b");        相对于该代码所在 ...

  9. HDU Sky数 2097

    解题思路:类比求出10进制数各个位上的数字之和,求出12进制和16进制上的数. #include<cstdio> #include<cstring> #include<a ...

  10. web.xml 中的listener、 filter、servlet 加载顺序

    在项目中总会遇到一些关于加载的优先级问题,近期也同样遇到过类似的,所以自己查找资料总结了下,下面有些是转载其他人的,毕竟人家写的不错,自己也就不重复造轮子了,只是略加点了自己的修饰. 首先可以肯定的是 ...