It all started when I tried to work with SharePoint webservices. In this post in stackOverflow , Gloria has defined that if we get a WSDL file then we will be able to get the services in UFT.There was another great post in stackoverflow, showing to define and call an API test from GUI test. I compiled all of them and came up with a set of steps that can be performed to configure Sharepoint Webservices and get data from it using UFT.
As per MSDN site if we get the sharepoint url , and add “_vti_bin/Lists.asmx?WDSL” to the end of the url ,I will be able to get the WSDL file for the corresponding url.
The WSDL will look like- http://server:port/ _vti_bin/Lists.asmx?WDSL.
By this way, I was able to transformed the sharepoint url to equivalent WSDL file. Precondition was to have access to the sharePoint.
Here is a step by step guide to configure the same in UFT and make it a Reusable API Call.
Open UFT–> Click on New–>Test–>Select API Test–>Provide the Name of the script–>select the location to save the script–>Click ok
Double Click on the Test Flow–> Click on Import WSDL(situated in the second ribbon , just under run)–>Select import from URL Checkbox and provide address as the WSDL link we have created above–>Click ok
In the left hand side , we will find tool box. If we observe the toolbox, we will get two activities:
1. Local Activities if expanded we will get the webservices–>Lists SOAP–>Methods
2. Standard Activities if expanded we will get the list of standard operations
Drag any services for example I have dragged- GetListAndView into test folder from the webservices list. Also drag WriteToFile from standard activities. The objective here to get the response from the API call and store in a File for further processing.
Go to right hand side of the test folder, we will get properties,under properties we will find a drop down . Select start there. Upon selecting start, we need to go to the test input/output parameters.
We need to create Input parameters as –
The objective is to call this API test from some other test and pass these values as parameter to this test.
Select the same drop down to get GetListAndView(The service name) under properties.Under Test input/output parameter –>Click on Grid–>If we scroll further down, we will get Body tag. Under that we will find ListName.
Click on the anchor icon (Link to data source)–>This will open a new window–>Under Link from section–>select available steps radio–>inside Test–> Select Start–>right side , it will open all available parameters—>Select ListName–>Click ok
Now we can see under Body tag the listName value will be binded as
equivalent xml will be:
In this step we need to tell UFT to store the output result to a file. Select writeToFile operation under properties from the dropdown.
We can see there are set of inputs. We need to set them one by one. I have set the below values:
Similarly select the anchor icon(Link to data source)–> this content is nothing but our response xml of the webservice. So select the “available steps” radio in the “Link from” level
Select TestFlow–>GetListAndView(the service name) –>go to the output tab–>Expand the body till second level–>Select the node whose child is any.
For this case it was GetListAndViewResult–>Click ok
The key content will have the value as–
Set Mode->Select create new file. I always prefer this as output is not messed up. It always create a new file.
Append new Line–> true
Set File Path–> This is where we will instruct UFT to store the file in the user defined name and path.Click on the anchor icon(Link to data source)–>It will open a data source to link–>select available steps radio in the link from area.
Expand Test–>Select Start–>right hand side, we will see all the parameters created under Start–>Select FileName–>Click ok
The key File path will be populated with the value–
Now we have successfully created the reusable webservice Test.