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. 用Visio画UML顺序图

    1.顺序图 顺序图又称为时序图,顾名思义,它着重表现的是对象间消息传递的时间顺序.顺序图描述的对象也是一个用例,即一组行为操作,而它表现的是这组行为的先后关系(纵坐标),以及每个行为是属于哪个对象的( ...

  2. 修改Eclipse格式化代默认长度

    eclipse 默认设置的换行长度为80, 格式化代码后,同一个方法里面参数也经常被,换行,非常难看 1.Java代码打开Eclipse的Window菜单,然后 Preferences->Jav ...

  3. HDU 1505 City Game

    这题是上一题的升级版 关键在于条形图的构造,逐行处理输入的矩阵,遇到'F'则在上一次的条形图基础上再加1,遇到'R'则置为0 然后用上一题的算法,求每行对应条形图的最大矩阵的面积. 另外:本来是deb ...

  4. 【英语】Bingo口语笔记(60) - 口语中的浊化发音

  5. 【英语】Bingo口语笔记(72) - play系列

  6. 【自动化测试】Selenium处理富文本框

    http://blog.csdn.net/fudax/article/details/8089404 selenium处理富文本框,日历控件等 调用JS修改value值 document.getEle ...

  7. 【转】eclipse怎么设置字体大小

    原文网址:http://jingyan.baidu.com/article/f96699bb9442f3894e3c1b15.html 1. 打开eclipse,找到window 2.  点击后在下拉 ...

  8. OpenGL ES之GLSurfaceView学习一:介绍

    原文地址::http://120.132.134.205/cmdn/supesite/?uid-5358-action-viewspace-itemid-6527 GLSurfaceView是一个视图 ...

  9. 小结JS中的OOP(中)

    此篇文章主要是提炼<JavaScript高级程序设计>中第六章的一些内容. 一:JS中OOP相关的概念 开始之前先总结JS中OOP相关的一些概念: 构造函数:JS中的构造函数就是普通的函数 ...

  10. ANT 发布项目中 build.xml 文件的详细配置

    xml 代码 <?xml version="1.0" encoding="UTF-8"?> <!-- name:对应工程名字 default: ...