How can I validate Postman API response contains the String mentioned CSV file - testing

When running a Postman requests through Collection runner by passing the values contain in a CSV file for the input parameters, how can I validate each response contain the String text mentioned in the expected value column in this CSV file. I also want to write each response to the Actual result column in this CSV file.
For example after executing the 1st request in the above pic using the Postman collection runner I want to validate the response contains 'Sydney' as a text value and give the result as 'PASS' or 'FAIL' as well as write the actual response to the Actual result column of the above file. This should continue till the last row of the CSV file.

You can access the data in the CSV using the data dictionary, for example data.Scenario.
Checkout this article, chapter "Data variables in pre-request and test scripts".
I don't think it is possible to write data back to the CSV file.

Related

Values of a particular column of CSV file is not fetched properly in Json payload (Karate Framework)

I am working on specified scenario too.
My .csv file is as follows:
And test steps are:
Scenario Outline: Create new content value for movie: '<Movie>'
When json payload = {'attributes':[{'entity_attribute_id': 41,'value': '<Genre>'},{'entity_attribute_id': 42, 'value': '<Language>'},{'entity_attribute_id': 39,'value': '<Movie>'},{'entity_attribute_id': 101,'value': '2020-12-03'}],'entity_type_id': '10'}
Given url baseUrl + postContentValues
And request payload
When method post
Then status 200
And print response
And def contentId = response.id
Examples:
|read('RoughTable.csv') |
On test execution, "Movie" are not fetched while "Genre" & "Language" are obtained as expected from .csv file
Please guide me for solving this issue.
I think there may be an issue with CSV loading. Can you add an extra dummy column before Movie.
Either way, please submit a way to replicate, this will help us fix it: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Is there any way to store array/list as variable/parameter in constructing an API in Postman?

I'm trying to parameterize a url in Postman and loop over that list to call multiple APIs one after another and append the JSON bodies.
For example:
if the url is GET https://location/store/{{user_id}}/date
and
user_id = ['1','3','5','2','6','8']
then how do I store user_idas a variable such that request can loop over each user_idin the url and generate an appended JSON body?
You can use data files. Store the user id values into a csv or JSON file and call that file in to your collection runner. The headers of the csv files can be used as variables names. please see the details of this approach in the below link
https://learning.postman.com/docs/postman/collection-runs/working-with-data-files/

Conditionally, Converting of JSON to XML using MuleSoft

I have a simple conversion of JSON to XML using MuleSoft. In "Transform Message" component, I provided JSON Schema as Input and XML Schema as Output. When I run the app, the conversion happens if the file matches with both schema but it generates an empty XML file if it doesn't match.
I want below conditions:
1) If the file matches with schema, the converted output file should be sent to converted folder and the original file should move to Success folder.
2) If the file doesn't match with schema, the original file should move to the Failure folder instead of conversion.
Hope, I explained it comprehensively as I am new to MuleSoft. Here is a sample diagram which may simplify my requirement. Provide me with a new one if I badly designed the process.
First thing you need to create a flowVar that will hold your original payload.
When your doing your evaluation, if its XML then use a simple XPath expression like //elementName[not(node())]
Lastly, on your success use scatter-gather for multi-threading write. Pull your original payload from flowVar and write to Success and Write your regular payload to your Converted folder

Jmeter - read parameters from csv and write back updated parameters

I'm using Jmeter for testing. I need to use some keys in order to perform login, and then change the keys.
I understood that the best way to do it is to create csv file that contains two variables.
I understand how I can read the parameters (using 'CSV Data Set Config'), but I still don't know how to extract specific parameters from result (new keys) and save them in file instead the old ones.
You can use Regular Expression Extractor to extract the values from the response. This site will give you an idea how it works.
It is NOT a good idea to write in the same file which is read by CSV dataset config. Instead, you can use Beanshell post processor to create a CSV file & write as you want.
import org.apache.jmeter.services.FileServer;
f = new FileOutputStream("/your/file/path/filename.csv", true);
p = new PrintStream(f);
p.println("content,to be,written,in,csv,file");
p.close();
f.close();

How to retrieve the data(String) from text file and send into particular field in application using java (selenium webdriver.)

I have tried to get the data from text file it worked , but unable to send the same data to particular field in application.
Store that text in string variable and send it using sendKeys(your_string) method.