Data Import from CSV or XML
SOAP Newbie here.
Successfully created my first SOAP Project and request to create a record.
Now how can I do a mass import by getting the data from a csv/xml source file and then loop through my soap request?
Thanks in advance!
There's lots of different ways to do this - some of other lads on this site will provide alternatives - but the way I would do this is as follows:
If it's SOAP - did you create the project from a .wsdl file? Cos that'll make this easier.
I save the test data files to an appropriate directory (call it c:\testdata\test1\whatevs.xml)
I use a datasource (directory type)
SOAP POST request (the body of the request will populated with the testdata file)
Datasource loop
so my test case's test step hierarchy is as follows:
Datasource SOAP POST request Datasource Loop
OK - low level instructions to do the above are as follows:
Create the test suite object within your project
Create the test case objecct within your project
Right click and click on the 'Add Step' - this launches the 'Add Step' form, click on 'OK' to accept the Datasource step name.
A 'Generate Properties' dialogue launches, I always click 'No' at this point and I come back to this later.
On the 'Datasource' step, click on the 'Data Source' dropdown and select 'Directory'
Click on the 'Select directory' 'Browse' button to navigate to the directory in which your testdata files reside (e.g.c:\testdata\test1)
In the 'Filename Filter' field, input '*.xml'
Within the 'Properties' frame on the Datasource step, click on the green plus ('Add Property') - an 'Add Property' form launches - input 'fileContents'.
Click on the green right arrow, which launches a form entitled 'Test data source' - the field auto populates with '10' - you need to alter this to '1'
Within the test case hierarchy, right click on the 'Datasource' object within the test case in the 'Navigator' frame.
Right click and click on the 'Insert Step' and select 'SOAP Request' - 'Add Step' form launches, click on 'OK' to accept the name for the SOAP test step, this launches a 'New Request' form to select the SOAP request - click on 'OK', this launches an 'Add Request to TestCase' form - click on 'OK' button - this adds the SOAP request to the test case.
Within your test case hierarchy, highlight the SOAP request test step, and within your 'Request' frame, you have 4 vertical tabs (Form, Outline, Raw, XML).
Click on the 'Outline' tab, identify the SOAPBody tag (which equates to the operation name tag in your .wsdl) - the SOAPBody tag is the tag the should contain your .xml payload
Right click and select 'Get Data' - this launches a 'Get Data' form which is split vertically into 4 columns (Test Suite, Test Case, Test Step, Properties)
Click on the 'Datasource' in the 'Test Step' column which auto populates the 'Properties' column with the 'fileContents'.
Click on the 'fileContents' within the 'Properties' column and click on the 'Add' button to accept the changes and close the 'Get Data' form.
Within the test case hierarchy, right click on the 'SOAP Request' object within the test case in the 'Navigator' frame.
Right click and click on the 'Insert Step' and select 'Datasource Loop' - 'Insert Step' form launches, click on 'OK' to accept the name for the Datasource Loop test step.
Ensure the test step hierarchy is as I specify above (Datasource, then SOAP Request, then Datasource Loop)
Double click on the 'Datasource Loop' object to launch the 'Configure Datasource Loop' form.
Click on the 'Target Step' dropdown, select the 'SOAP Request' step and click on 'OK' to accept the changes and close the form.
That's it - you should be good to go - this test case will execute once thhrough all the .xml files saved in the directory specified. Don't forget - you'll need to specify the appropriate authorisation on the SOAP Request step before the SOAP request will POST successfully.
Hope this helps,
Cheers,
richie