Forum Discussion

tdichter's avatar
tdichter
Occasional Contributor
14 years ago

How to invoke Test Execute from DOS command line providing external parameters

Hi,



My background is in C, Java, Python development. On a new project I work on, I have to build a Test Complete framework to simulate various Windows user level scenarios to be used by the QA team.



this is what I need to do (small part of the project):



1.  Write a function which gets a string representing a UNC Windows path to a remote CIFS file server – I.E \\\\1.1.1.1\\share_1 – the functions name is: view_directory_listing (p_str_unc_path) – the method returns a list of the files/folders under the above UNC path. (please see below on how its implemented – as seen, very simple…)


2.  Write a main function which is invoked externally from the DOS command line on a Test Execute client – the main will get 2 parameters, the name of the method to invoke and a string which is the UNC path to provide.


3. Both the aboe methods are written in the same Unit in the Test Complete project.



4.  On the Test Execute machine, I copied the content of the project to a location under drive C.


This is the command line I invoke on the Test Execute machine:


C:\Test_complete_proj\VSS_1\VSS_1.pjs /r /p:VSS_1 /u:vss_script_1 /rt:main view_directory_listing \\\\10.1.1.149\\dev


As seen - I provide to the routine main the 2 parameters (maybe there is a problem in this - I didnt see in the documentations on how to invoke Test Complete methods providing external params...)


When I run this command, nothing happens, I don’t get an error message as well.


Note: I know that Test Execute runs well on that client, when I type: “c:\Program Files\Automated QA\TestExecute 8\bin\TestExecute.exe” – I get a message that a Test Execute instance is already running…


Here are the two methods code:


 

function main (p_str_methods_name,p_str_param)


{


  if(p_str_methods_name == "view_directory_listing") {


    directory_list = view_directory_listing(p_str_param);


    Log.Message("Dir list of " + p_str_param + " is: " + directory_list)


  }


}


function view_directory_listing(p_str_unc_path)


{


  var explorer;


  var comboBox;


  var wndCabinetWClass;


  explorer = Aliases.Explorer;


  explorer.wndShell_TrayWnd.btnStart.ClickButton();


  explorer.wndBaseBar.MenuSite.ToolbarWindow32.ClickItemXY("&Run...", 32, 23, false);


  comboBox = explorer.dlgRun.ComboBox;


  comboBox.SetText("p_str_unc_path");


  comboBox.Edit.Keys("[Enter]");


  wndCabinetWClass = explorer.wndCabinetWClass;


  fileList = slPacker.GetFileListFromFolder(p_str_unc_path);


  wndCabinetWClass.Close();


  return fileList;


}


Can you please assist me on that?

I am sure that something small is missing here....



Thanks,

Tomer

7 Replies

  • tdichter's avatar
    tdichter
    Occasional Contributor
    Note:



    I tried even with a main routine which doesnt get any parameters, I.E:


    function main_1()


    main_1()

    {


    directory_list = directory_list = view_directory_listing(\\\\10.1.1.1\\dev);


    Log.Message("Dir list of is: " + directory_list);


    }



    I copied the changed project and renamed it, so that the DOS command line was this:


    C:\Documents and Settings\Administrator>C:\Test_complete_proj\VSS_2\VSS_1.pjs /r /p:VSS_1 /u:vss_script_1 /rt:main_1


    C:\Documents and Settings\Administrator>


    As seen, no script activation occurred...



    Any ideas what is missing here?



    please let me know,



    thanks,



    Tomer






  • 1. Kill proccess TestExecute.exe

    2. Run in cmd

    c:\Program Files\Automated QA\TestExecute 8\bin\TestExecute.exe C:\Test_complete_proj\VSS_2\VSS_1.pjs /r /p:VSS_1 /u:vss_script_1 /rt:main_1
  • tdichter's avatar
    tdichter
    Occasional Contributor
    Hi,



    thanks alot for the tip Nikita, with this command line I am able to execute the scripts on the test execute machine.



    Jared, I went over the lilnk you sent, it works fine - however, I want to provide more than one custom command line parameter, and it looks like only one is parsed by the "BuiltIn.ParamCount()"



    This is the command line to send to Test Execute:

    C:\Documents and Settings\Administrator>"c:\Program Files\Automated QA\TestExecute 8\bin\TestExecute.exe" C:\Test_complete_proj\VSS_2\VSS_1.pjs /r /p:VSS_1 /u:vss_script_1 /rt:main_1 /method_name=view_dirs /unc_path=\\\\1.5.2.1\\testing



    in the method main_1, I print to the Log the parameters:

    function main_1() {

     BuiltIn.ParamCount()

     param_count = BuiltIn.ParamCount();

     Log.Message("param count is: " + param_count );

     for (var i = 0 ; i < param_count; i++ ) {

      Log.Message("param in counter # " + i + " is: " + BuiltIn.ParamStr(i));

     }  

    }



    in the log messages - I see only the "/method_name=view_dirs" - but not the "/unc_path=\\\\1.5.2.1\\testing"



    When I replace the parameters order in the command line, I.E:

    C:\Documents and Settings\Administrator>"c:\Program Files\Automated QA\TestExecute 8\bin\TestExecute.exe" C:\Test_complete_proj\VSS_2\VSS_1.pjs /r /p:VSS_1 /u:vss_script_1 /rt:main_1 /unc_path=\\\\1.5.2.1\\testing /method_name=view_dirs



    I see the "/unc_path=\\\\1.5.2.1\\testing" and not the "/method_name=view_dirs"



    I added the script's Log messages prints in the image attached.



    Can you please let me know how can I transfer as many arguments as I can to the command line using this approach?



    Thanks,

    Tomer






  • Hi Tomer,



    Use 'BuiltIn.ParamCount() + 1' instead of 'BuiltIn.ParamCount()'. It returns the number of parameters which follow the path to TC/TE's executable which is parameter #0.
  • Tomer Dichterman 0_o U use VERY huge commad line! Why?



    Let's do easy



    Before running TestExecute preparing some config file, f.e., ini-file with content

    [Main]

    Param=1

    Param=2

    Param=3



    And then just run TE

    c:\Program Files\Automated QA\TestExecute 8\bin\TestExecute.exe C:\Test_complete_proj\VSS_2\VSS_1.pjs C:\Test_complete_proj\VSS_2\Config.ini



    And in script VSS_1.pjs write proc/func for read from ini 



    GL HF :)
  • tdichter's avatar
    tdichter
    Occasional Contributor
    Hi Nikita,



    Thanks, actually, we want to avoid using hard coded configuration files - since the parameters to the command line are very dynamic - meaning that in each run we need to provide different command line parameters (which change depending on the machines you run the code on...)



    I got an earlier tip to user the:

    BuiltIn



     



     



    .ParamCount() + 1; (or + any value of the additional parameters in the command lines)



    Ill see how this works before "forcing" the QA to have these config files instead...



    thanks again for the help guys!



    Tomer