将类数组传递给 QTP/VBScript 中的动作参数 [英] Passing array of classes to parameter of action in QTP/VBScript

查看:48
本文介绍了将类数组传递给 QTP/VBScript 中的动作参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题涉及 QTP/VBScript 的使用.

My question involves the use of QTP / VBScript.

目标:从 qtp 主起始文件中,初始化一个类数组,然后将该数组作为参数传递给可重用的操作.

Goal: From the qtp main starting file, initialize an array of classes, and pass that array as a parameter to a re-usable action via a parameter.

问题:我无法将一组类传递给我的可重用操作.

Problem: I am not able to pass an array of classes to my re-usable action.

详情:

我有两个文件:application_main"personal_action".

I have two files: "application_main" and "personal_action".

application_main 是 qtp/vbscript 的入口点.
Personal_action 是一个可重复使用的动作

application_main is the entry point into qtp/vbscript.
personal_action is a re-usable action

在 application_main 中,我们调用了 InvokeApplication,然后进行了一些其他声明.

Inside application_main, we have a call to InvokeApplication, proceeded by a few other declarations.

我能够初始化一个数组并继续将它作为参数从我的 application_main 传递给我的personal_action:

I am able to initialize an array and proceed to pass it as a parameter from my application_main to my personal_action:

来自 application_main:

Dim myArray
myArray = new Array(object1, object2, object3)
RunAction "personal_action", oneIteration, myInteger, myBoolean, myArray

在personal_action页面上,我通过以下方式编辑参数属性:
编辑->动作->动作属性.我选择了参数标签.
在其中,我可以选择定义传入参数的数量和每个单独的类型.这些可用类型似乎仅限于:

On the personal_action page, I edit the parameter properties via:
Edit->Action->ActionProperties. I select the Parameters tab.
In it, I have the option to define the amount of incoming parameters and each individual type. These available types seem to be restricted to:

字符串、布尔值、日期、数字、密码、任何

我将第一个参数设置为:Number
我将第二个参数设置为:Boolean
我将第三个参数设置为:Any

I set my 1st parameter as: Number
I set my 2nd parameter as: Boolean
I set my 3rd parameter as: Any

运行时,提示我:

您在 RunAction 中为myArray"参数指定的类型语句与操作中定义的类型不匹配.

The type you specified for the ‘myArray’ parameter in your RunAction statement does not match the type defined in the action.

问题: 我可以很好地传递数字和布尔值,但是当涉及到数组时,qtp/vbscript 似乎不能很好地处理它.为什么我无法通过主启动文件中的参数将数组传递给操作?这似乎是一项常见而简单的任务.我会这么错吗?

Question: I am able to pass the Number and Boolean fine, but when an array is involved, qtp/vbscript doesn't seem to handle it well. Why am I not able to pass an array to an action via parameters from the main startup file? This seems like a common and simple task. Could I be so wrong?

感谢任何帮助.谢谢.

推荐答案

据我所知,QTP 将不允许允许这样做.没有可用于表示数组的参数类型.这可能是 QuickTest Professional 的限制.

As per my knowledge, QTP will NOT allow this. There is no parameter type that can be used to represent an Array. This might be a limitation of QuickTest Professional.

您可以将 Array 元素作为用分隔符分隔的字符串传递,而不是传递数组.

Rather than passing array you can pass the Array elements as a string separated with delimiters.

示例:"Item1^Item2^............" 其中 "^" 是分隔符然后你可以使用 vb 脚本的 split 函数,来获取你的数组.

Example: "Item1^Item2^............" where "^" is the delimiter then you can use split function of vb script, to get your array back.

再次对对象做同样的事情,我们必须为此尝试

Again doing the same thing with object,we have to give try for this

这篇关于将类数组传递给 QTP/VBScript 中的动作参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆