QTP: strengthening of parameterized scripts

step:

        1. Analysis script requires data parameterization
        2. substitute the parameter in the keyword views
        3. Set parameter data source
        4. The call attribute setting operation
        5. Playback verification

A, DataTable- most common

Sheet according to the Global table or table data is performed line by line, the data provided in advance of doing so.

SystemUtil.Run "C:\HP\QTP\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set DataTable("p_Text", dtGlobalSheet)
Dialog("Login").WinEdit("Agent Name:").Type  micTab 
Dialog("Login").WinEdit("Password:").SetSecure DataTable("p_Text1", dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Type  micReturn 
Window("Flight Reservation").Close

Second, the random number

A random number, a random number in an interval, and then fill in the specified location, and the like for the following frame.

SystemUtil.Run "C:\HP\QTP\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set RandomNumber(1000, 2000)
Dialog("Login").WinEdit("Agent Name:").Type  micTab 
Dialog("Login").WinEdit("Password:").SetSecure DataTable("p_Text1", dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Type  micReturn 
Window("Flight Reservation").Close

Third, the environment variable

After you set the environment variable, the value is always the value of the environment variable settings, unless the next manually change it, change will not happen.

Static environment variable - not the system default custom modifications 

TestDir:当前测试脚本目录
TestName:当前测试脚本名称
ActionName:当前测试脚本Action名称
ProductDir:当前产品的安装路径
ResultDir:当前脚本测试报告保存路径
LocalHostName:本机计算机名称

Dynamic environment variables - you can customize Import and Outsourcing

获取环境变量的值:Envionment(“VarName”)
设置环境变量的值:Envionment(“VarName”) =“test”
SystemUtil.Run "C:\HP\QTP\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set Environment("ResultDir")
Dialog("Login").WinEdit("Agent Name:").Type  micTab 
Dialog("Login").WinEdit("Password:").SetSecure DataTable("p_Text1", dtGlobalSheet)
Dialog("Login").WinEdit("Password:").Type  micReturn 
Window("Flight Reservation").Close

 

 

 

Published 349 original articles · won praise 161 · views 190 000 +

Guess you like

Origin blog.csdn.net/qq_42192693/article/details/103675360