简体   繁体   English

如何将参数从UFT传递到命令行

[英]How to pass arguments from UFT to command line

I am trying to run tests in UFT by running a .vbs file. 我试图通过运行.vbs文件在UFT中运行测试。 I am also passing arguments through command line. 我也通过命令行传递参数。 .vbs file reads the arguments and sets the environment variable of UFT. .vbs文件读取参数并设置UFT的环境变量。 Hence, I can read them inside UFT. 因此,我可以在UFT中阅读它们。

qtApp.Test.Environment.Value("First_Argument") = WScript.Arguments.Item(0)
qtApp.Test.Environment.Value("Second_Argument") = WScript.Arguments.Item(1)

After that, I want to get a number as an output from UFT because I will use that output to pass it to the next command in command line. 之后,我想从UFT获得一个数字作为输出,因为我将使用该输出将其传递给命令行中的下一个命令。

The Test Parameters Object can be a way , more detailed in the Automation Object Documentation 测试参数对象可以是一种方法,有关详细信息,请参见自动化对象文档

You will have to define the TestParameters of the TestCase from the UFT IDE(manually) there is no way to define them automatically. 您将必须从UFT IDE定义TestCase的TestParameters(手动),无法自动定义它们。 If you declare them as in and out type, and change their value as a part of a Test Case, you would be able to read it afterwards from the vbs (Do not open a new Test Case until you did not read out the preferred values) 如果您将它们声明为输入和输出类型,并在测试用例中更改其值,则以后可以从vbs中读取它(在未读出首选值之前,请勿打开新的测试用例。 )

Although this is a working (and standard) way for exchanging parameters between the driver script and the TA Robot(UFT) I would advise you to use a simple file based way of doing this - managing test parameters can be very time consuming. 尽管这是在驱动程序脚本和TA Robot(UFT)之间交换参数的一种可行(标准)方法,但我还是建议您使用基于文件的简单方法来进行此操作 -管理测试参数可能非常耗时。

Tell the script via an Environment variable the path of the xml / json or simple text file where you expect the results to be written and when the test is done, read the content of the file (assuming the test will write into that file) 通过环境变量告诉脚本xml / json或简单文本文件的路径,您希望将结果写入该路径,并在测试完成后读取文件的内容(假设测试将写入该文件)

The plain old file way should not be underestimated especially in such circumstances. 特别是在这种情况下,不应低估原始的旧文件方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM