Forum Discussion
Hi dhirendranaga,
There's no way to pass a variable directly through a command line, but you can use a data source outside of TestComplete to set a variable value. This could be an Excel file, CSV, or any ODBC compliant database. Essentially, your Project could read that data source and set the Project level variables as the first step in the test set.
Some reference links on this below.
Data Driving a Test Case in TestComplete
-Dan
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).
- dhirendranaga11 years agoOccasional ContributorThank you very much, will give a try.
- HKosova11 years ago
Alumni
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);- NisHera11 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...