Forum Discussion
You could also set an environment variable and then read it in your test
http://support.smartbear.com/viewarticle/70788/ "GetEnvironmentVariable Method"
(Note that this won't work if you have enabled support for Windows Store apps on Windows 8 and up due to permissions issues).
- HKosova9 years agoSmartBear Alumni (Retired)
Actually it's possible to pass data via command line, but you'll need to parse the command line manually.
You can pass data as named parameters:
TestComplete.exe <common params> /MyVar1:value1 /MyVar2:"Value with a space"
In your test, use BuiltIn.ParamCount and BuiltIn.ParamStr(index) to loop through the parameters and find your custom ones:
// JScript var nArgs = BuiltIn.ParamCount(); var paramStr; for (var i = 1; i <= nArgs ; i++) // starting from 1, because arg 0 is the TestComplete path { paramStr = BuiltIn.ParamStr(i).split(":"); switch (paramStr[0]) { case "/MyVar1": Project.Variables.Var1 = paramStr[1]; break; case "/MyVar2": Project.Variables.Var2 = paramStr[1]; break; } } Log.Message(Project.Variables.Var1);
Log.Message(Project.Variables.Var2);- NisHera9 years agoValued Contributor
Good to know...
Would you please add this example to help (or what ever relevent) documentation.
was struggling to run
Project A then Project B and then Project A with deferent test parameters in a single run.
this helps...
- HKosova9 years agoSmartBear Alumni (Retired)
Hi Nishera,
It's on our todo list, thanks for the suggestion!
- Colin_McCrae9 years agoCommunity Hero
Thats very much how it works with standard Python. And handy to know! Thanks. :)
Related Content
- 5 years agoKrishna_Kumar
- 2 years agoTestQA1
- 3 years agoloricotton
- 8 years agomuralidharan18