How to write to data file in API test
I am learning the api test using UFT. I have done the following.
1. added concatenated strings to canvas. Prefix is pointing to a column which has 3 rows. Suffix is pointing to another column which has 3 rows. That means I have a local table with two columns prefix and suffix with 3 rows of data.
Properties tab > Prefix and suffix value pointing to corresponding column in data source.
2. Added "file created" to canvas.
Overwrite = true
3. "Write to file" added to canvas.
Content = pointed to data source.
File path = same as step 2.
mode = append to existing file
encoding = ASCII
Apprend new line = true
When I run my test, I expect 3 rows of data to be inserted into the file. But I only get the last row data from data source. How can I have 3 rows of data in the file?
HelloI am preatty sure how to solve your problem,
What is happening is that you have an two step on your canvas the first is concatenating tyour 3 rows as expected, and after that your are writing the result to the file, and that result would be the result of the last iteration,
what you need to do is go to your test flow an use the 'For Each' Loop and Loop for each item in : DataSource.Concatenated Strings
thay way the API will concatanate the string, write to file and then the new iteration will begin and so on...
I hope this helps,
I attach some screnshots to show you how I did it