Forum Discussion
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".
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.
- tristaanogre8 years agoEsteemed 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?
- tristaanogre8 years agoEsteemed Contributor
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.
- scambias8 years agoContributor
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