Forum Discussion

b_cross's avatar
b_cross
Occasional Contributor
11 years ago

Set number of iterations from a user form

Hi 



I have set up a user form that allows me to set some optinal test conditions from this form id also like to change the number of time a test case will run. 



i can find the current set value using: Project.TestItems.TestItem(0).TestItem(0).Count()

but i don't see how i can up date this value from a combo box on a user form 



Any help would be welcome 









  • I don't believe the count property can be modified during run time. You can however just call your main function of your script based on the number of iterations in your combo box.



    function main(){

    UserForms.MyForm1.ShowModal();

    }

     

    function readmycombobox(r){

    /*

    1. Create a button (TcxButton)

    2. Create a procedure with Project.TestItems.TestItem(0).TestItem(0).Count()

    3. Call the procedure from the buttons OnClick event

    4. Include a read of the combobox in the procedure with UserForms.FormName.cxComboBox1.Text

    */

    var tmp = UserForms.MyForm1.cxComboBox1.Text;

    for (var c = 0;c < tmp;c++){

     drivetests();

     }

    }



    function drivetests(){

    /*

    Testing script stuff here...

    */

    }



































  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    I don't believe the count property can be modified during run time. You can however just call your main function of your script based on the number of iterations in your combo box.



    function main(){

    UserForms.MyForm1.ShowModal();

    }

     

    function readmycombobox(r){

    /*

    1. Create a button (TcxButton)

    2. Create a procedure with Project.TestItems.TestItem(0).TestItem(0).Count()

    3. Call the procedure from the buttons OnClick event

    4. Include a read of the combobox in the procedure with UserForms.FormName.cxComboBox1.Text

    */

    var tmp = UserForms.MyForm1.cxComboBox1.Text;

    for (var c = 0;c < tmp;c++){

     drivetests();

     }

    }



    function drivetests(){

    /*

    Testing script stuff here...

    */

    }



































  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    1. Create a button (TcxButton)

    2. Create a procedure with Project.TestItems.TestItem(0).TestItem(0).Count()

    3. Call the procedure from the buttons OnClick event

    4. Include a read of the combobox in the procedure with 
    UserForms.FormName.cxComboBox1.Text
  • b_cross's avatar
    b_cross
    Occasional Contributor
    Any chance you could right an example of the procedure and the read



     
  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    Create a userform named MyForm1

    Add a TcxButton

    Add a TcxComboBox

    Set the OnClick event of the TcxButton to: readmycombobox

    Run the main() function

    Type in the TcxComboBox

    Press the TcxButton




    function main(){


    UserForms.MyForm1.ShowModal();


    }


     


    function readmycombobox(r){


    /*


    1. Create a button (TcxButton)


    2. Create a procedure with Project.TestItems.TestItem(0).TestItem(0).Count()


    3. Call the procedure from the buttons OnClick event


    4. Include a read of the combobox in the procedure with UserForms.FormName.cxComboBox1.Text


    */


    var tmp = UserForms.MyForm1.cxComboBox1.Text;


    wshell = new ActiveXObject('WScript.Shell');


    wshell.popup('Your number of iterations would be: ' + tmp);


    }

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    And to process test items you can find this in the help file:



    function Test()

    {

      var i, TestItems, Count;

      // Obtains the collection of project test items

      TestItems = Project.TestItems;

      // Defines the total number of test items in the project

      Count = TestItems.ItemCount;

      // Iterates through the project’s test items

      for (i = 0; i < Count; i++)

        ProcessTestItem(TestItems.TestItem(i));

    }



    function ProcessTestItem(ATestItem)

    {

      // Posts the test item name

      Log.AppendFolder(ATestItem.Name);

      // If the test item contains child items, iterates through them

      for (var i = 0; i < ATestItem.ItemCount; i++)

        ProcessTestItem(ATestItem.TestItem(i));

      Log.PopLogFolder();

    }  
  • b_cross's avatar
    b_cross
    Occasional Contributor
    Thanks for your help i'm still not able to achieve the outcome I was looking for but have come to the conclusion it's not possible or beyoned my ability for now.



    while I can read the value I just cant find a way of using it to define the number of iteraions of a single test item.



    The help file doesn't really help as it's just doing 1 iteration of child / sub test items



    I can display the current set value (see attachment) on the form using:




    function MyForm1_OnShow(Sender)


    {


    UserForms.MyForm1.cxComboBox1.Text(Project.TestItems.TestItem(0).Count) 


    }



    I just can't seem to pass a new value back






     
  • b_cross's avatar
    b_cross
    Occasional Contributor
    Thanks this gives me a soild starting point for achieving what i wanted