Forum Discussion

IrisL's avatar
IrisL
Occasional Contributor
13 years ago

Can I ask for parameter by starting TestExecute via command line

Hi,

is it possible to start TestExecute via commad line and give a value for the parameters given in TestComplete?

I defined parameters for a KeywordTest and want to start the test via batch-file on a virtuell machine, for example with:

"C:\Program Files (x86)\Automated QA\TestExecute 8\Bin\TestExecute.exe" "I:\Test\Project_Suite.mds" /r /p:Project /exit

Is it possible to give also a value for the defined parameters when starting TestExecute?

Thanks,

iris
  • chicks's avatar
    chicks
    Regular Contributor
    Take a look at the BuiltIn.Param object.  Here's some sample code I'm using so I can pass different data files at startup.



    This is JavaScript.



    Regards,

    Curt





    function CommandLineArgs()

    {

      // start /wait "TestComplete" "C:\Program Files (x86)\Automated QA\TestComplete 8\Bin\TestComplete.exe" "C:\TestCompleteFiles\testcomplete\Shell_Member_Portal_suite\Shell_Member_Portal_suite.pjs" /p:MemberPortal /r /data="C:\\TestData\\MP_Shell.xlsx"

      //Parameter[1] =  C:\TestCompleteFiles\testcomplete\Shell_Member_Portal_suite\Shell_Member_Portal_suite.pjs

      //Parameter[2] = /p:MemberPortal

      //Parameter[3] = /r

      //Parameter[4] = /data="C:\\TestData\\MP_Shell_QA_Box.xlsx



      var nArgs = BuiltIn.ParamCount();

      var str;

      var args = new Array();

      var re = new RegExp("=","g");

     

     // Log.Message("Total number of command-line arguments: " + nArgs);

     // Log.Message("The fully-qualified name of the TestComplete executable: " + BuiltIn.ParamStr(0));



      var argumentFound = false;

      for (var i = 1; i <= nArgs ; i++) {

          str = BuiltIn.ParamStr(i);

          Log.Message("param = " + str);

          if ( str.indexOf("/data=") != -1) {

              argumentFound = true;

              Log.Message("data = " + str);

              args = str.split(re);

              Log.Message("args = " + args);

              excelData = args[1];

              myExcel = args[1];

             Log.Message("excelData = " + excelData);

             Log.Message("myExcel = " + myExcel);



          }  

      }

      if (argumentFound == false) {

         Log.Message("Data sheet was not specified in the command line. Default data sheet " +excelData + " will be used.");

      }

    }
  • IrisL's avatar
    IrisL
    Occasional Contributor
    Dear Curt,

    it still won't run, can you help again?



    The command line is like:

    "C:\Program Files (x86)\Automated QA\TestExecute 8\Bin\TestExecute.exe" "I:\Test\Project_Suite.mds" /r /p:Project /data&colon;"abc" /exit



    In the TestComplete Javascript i have this function without an index:

    function commandlineargs()

    {

    data = BuiltIn.ParamStr(3)

    Log.Message(data)

    }




    But by starting the batchfile, this error appears:



    The data parameter is just set in an editor:

    function Test1(data)

    {

      //Runs the "notepad" tested application.

      TestedApps.notepad.Run(1, true);

      //Enters  in the 'Edit' object.

      Aliases.notepad.wndNotepad.Edit.Keys(data);

    }




    Where and how do i have to define the parameters?



    Thank you,

    Iris




  • Anonymous's avatar
    Anonymous

    Hi Iris,





    What about using this command line?

    "C:\Program Files (x86)\Automated QA\TestExecute 8\Bin\TestExecute.exe" "I:\Test\Project_Suite.mds" /r /p:Project /data="abc" /exit



    (changed /data&colon;"abc" to /data="abc")
  • IrisL's avatar
    IrisL
    Occasional Contributor
    Hi Tanya,

    thank you, that doesn't work here. Should it run like this?

    Thanks,

    Iris
  • IrisL's avatar
    IrisL
    Occasional Contributor
    Hi Tanya,

    thanks! It runs. I had a syntax error in the bat-file. It wasn't the parameter....

    Thanks a lot!

    Iris
  • Anonymous's avatar
    Anonymous

    Hi Iris,



    That's great!



    BTW, we have a sample script in our How To demonstrating how you can work with TC's command line.