3

My question involves the use of QTP / VBScript.

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.

Details:

I have two files: “application_main” and “personal_action”.

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

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

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

From application_main:

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

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:

String, Boolean, Date, Number, Password, Any

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

Upon running, I am prompted with this:

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

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?

Any help is appreciated. Thank you.

user1466813
  • 31
  • 1
  • 3

3 Answers3

4

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.

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

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

Amol Chavan
  • 3,835
  • 1
  • 21
  • 32
0

use lib file in your action ... Create array public in lib but in end for any case test or interation vararray=null rodrigonw. Sugestion... use function for include your lib in your actions (lib path)

0
Lib soluction
''######################################LIB"
'lib Passsagem de valores entre array
Dim arrayyy()
Sub setArrayyy(strvalores,redimencionaArray)
  On error resume next 
  tamanho=UBound(arrayyy,1)
  If Err.Number=9 then 
   ReDim arrayyy(0)
   redimencionaArray=false
  end if
   err.Clear   
 On error goto 0
 If redimencionaArray Then 
  tamanho=tamanho+1
  ReDim  preserve arrayyy(tamanho)
 end if
 arrayyy(tamanho)=strvalores
 'arrayyy=arrayyy
End Sub

function getArrayyy()   getArrayyy=arrayyy End function

''######################################"'Action X

call setArrayyy("X",false)
call setArrayyy("A",true)
call setArrayyy("D",true)
call setArrayyy("B",true)
''######################################'Action y

x=getArrayyy()

for countx=0 to ubound(x)
msgbox x(countx)
next
cheesemacfly
  • 11,622
  • 11
  • 53
  • 72