Absent Member.. vzamoraz Absent Member..
Absent Member..

QTP/UFT support tip: How manage same iteration index from a called API test than the caller API test

If the purpose is that the called API test from Unified Functional Testing (UFT) runs the same datatable row index than the caller test(example:caller test is on its third iteration so called test will runs the third row of is own datatable) then there is a process that can be performed.


It would be necessary to handle it by variables and parameters with custom code.



How to do it:

1-From called test(secondary iteration in this sample) create a input parameter for Start(in the sample Param1)






2-From caller test add a new column in the Data table with incremental number in order to provide an index number for the rows( in this sample Column1 and  table name MainIterator)





3-Then call the secondary test and link the column with index(Column1) with the input parameter property.





4-Open second test, at the beginning of the test flow create a custom code activity





5-Create an input parameter for the custom code (in this sample RowNumber)





6-link the input parameter of start(parameter created on step 1) with RowNumber





7- Create the output values for the custom code action according to the columns of the secondary test Datatable.


In this sample Datatable has 2 columns





So in this sample there were created 2 output parameters with same name as Datatable columns





9-Save all the changes


10-Doubleclick on the custom code activity to move to the custom code page and create a function called setcurrentRow and add the code as below      


              public void setCurrentRow(object sender, STActivityBaseEventArgs args)
               //Set the variable MyRow with the index row passed from Param1 to RowNumer input parameter

  int myRow = Int32.Parse(this.CodeActivity6.Input.RowNumber);

//With the index obtained we can get the information of the specific row column of the datatable and assign it into the output parameters of the custom code activity.
               this.CodeActivity6.Output.FirstCol = this.GetDataSource("myDatatable").GetValue(myRow," FirstCol").ToString();
               this.CodeActivity6.Output.SecondCol = this.GetDataSource("myDatatable").GetValue(myRow,"SecondCol").ToString();


Now this output parameters can be used on thesecondary test to datadrive the next activities instead of datadrive them using directly the datatable.







Labels (1)
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.