Ask a Question

Using vbscript constant as Operational Parameters when calling a "run script routine"

scambias
Contributor

Using vbscript constant as Operational Parameters when calling a "run script routine"

Hi,

 

I have written a vbscript function that uses one argument.

In order to simply the meaning of this argument, I created some vb constants (simulating a kind of enumerative behaviour).

I would like to use these constant when I insert a "run script routine" inside a Keyword Test, as argument for this function.

Is this possible somehow?

8 REPLIES 8
tristaanogre
Esteemed Contributor

What you would do is, when setting up the "Run Script Routine", in the parameter, select "Code Expression" and then just enter the constant in the format of "UNIT.VARIABLE".

 


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Hi Robert,

 

Thank you for your answer.

I tried to, but it seems not to be working. What I get is an argument with "undefined" value.

 

By the way I tried also from a vbunit A to use a variabile myVar defined in unit B, by accessing with name B.myVar and it works.

 

tristaanogre
Esteemed Contributor

Can you post your code where you're creating these constants and then post a screenshot showing how you're attempting to use them in a Keyword test?


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Actually, just tried something in JavaScript.  You cannot call variables or functions in script routines as Code Expressions in a keyword test operation parameter.

 

So, in order for you to have access to those constants from a Keyword operation, you will need to expose them as some sort of global object...  This is where Script Extensions come into play as you can encapsulate your constants in a script extension as the properties of a Runtime Object... make them "Read Only" so they are kept as static constants.

 

The other option is to wrap your constants in a function that you could call and then set the result to a variable in your keyword test.  You can then use that variable as a parameter to any other function call.  But honestly, Script Extension is probably the way to go to make a more concise keyword test.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Thank you Robert,

 

I'll give a try even if I actually don't know anything about "Script Extensions". I'll study out this topic and let you know.

 

Thank you again,

Silvio

tristaanogre
Esteemed Contributor

Not a problem.

Actually, I'll be helping conduct a webinar next Tuesday on creating Script Extensions.  You can register at https://attendee.gotowebinar.com/register/1015263030297249537

 

It's actually a relatively simply process but it's EXTREMELY powerful in my opinion... rather under-utilized, I think.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Thank you!

What a coincidence: I was registered to this webinar which was supposed to be last tuesday. I have registered for next tuesday.

 

Thanks again.

 

Kind Regards,

Silvio

tristaanogre
Esteemed Contributor

Yeah, I had to cancel on last Tuesday... had a family emergency pop up. Looking forward to the upcoming event!


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: