Thursday 29 July 2010

Web services automation

I Have been working on software test automation using HP-QTP for some time now, so thought
to share my experience.

Topic: Web services automation
Web services are typically application programming interfaces (API) or web APIs that can be accessed over a network, such as the Internet, and executed on a remote system hosting the requested services.
Web service is one type of service that can be part of an SOA infrastructure, a web service is defined by a set of technologies that provide platform-independent protocols and standards used for exchanging data between applications.

In a very simple understanding, web services means functions that can be used by anybody from anywhere, so to make this possible these functions are placed on a web server, that is why such functions are called as web services.

There will be functions like tax calculation, credit checks which is used by different vendors, so these functions are updated in web server and that's why these are called web services. So these web services need to be verified with multiple inputs that is why we are using QTP to test our web services.

So for automating this kind of services needs a different approach of automation rather than normal GUI.
Following are the steps in automating the web services:
I am trying to give steps which you may not be able to use directly (because of some confidential info in it), the same steps can be used as a reference
Step 1. For testing web services the most important thing that we must know is WSDL(Web Services Description Language) location
Use the WSDL link in webservices wizard as shown

URL: URL for WSDL needs to be assaigned














Step2: Select the functionality

Once WSDL is selected, as a next step it displays all the functions associated with this web service
Select the desired function and place it in the selected options











Step3:Add xml checkpoint
Add the XML checkpoints after each relevent step














Step4: QTP Generates Web services test
This step confirms the test generation for the wb service function




Step5:
This step confirms the addition of xml checkpoints to the test





Step6:QTP generates web services testing function on editor














the generated code looks like:
' tir-port-typeService Web service object steps
Set tircalc = WebService("tir-port-typeService").tircalc(XMLWarehouse("tircalc_request"))
WebService("tir-port-typeService").Check CheckPoint("tircalc")

Step7: Go to Object repository and then to checkpoint points options














Step8: Click on drop down list of checkpoints and navigate till the values, then click on value and change it to get data from datatable and also copy the datatable name to excel.














Step9:Switch to the keyword view











Step10: select the function name and then click on regular expression button
Select parameter on the value configuration option -> XML structure -> existing (if you have dates in the xml format)










Select the parameter to parameterise the data, and click on edit xml structure













Parameter values looks like below:














Copy the name of values to xls to enter the data:

Import the .xls file and run for multiple iterations: Code

DataTable.Import("C:\Documents and Settings\Xyz49\Desktop\WebServices_Data.xls")

WebServices_Data.xls is the data file.

The code in the expert view looks as below:

' tir-port-typeService Web service object steps

Set tircalc = WebService("tir-port-typeService").tircalc(XMLWarehouse("tircalc_request"))

WebService("tir-port-typeService").Check CheckPoint("tircalc")

Run the test: (F5)

Verifying the results:













Click on “View XML checkpoint Results” and Verify the results
As the snap on the side shows which parameter data exactly failed.













Hope this article helps .. If you have any questions or suggestions please let me know..

1 comment:

  1. Hello Prashant,

    This is Devkant. I am trying to test web services but geeting issue.Please help.
    When i record the steps the code in QTP is like this:
    Set processWebService = WebService("WebServiceBrokerImplService").processWebService(XMLWarehouse("anyType"))

    I need to take input from a xml with me.I have imported that xml using edit xmlstructure but this test is getting failed while running. Error is:

    The processWebService operation call failed.
    The .NET Framework 2.0 WSE 3.0 toolkit returned the following error:
    There is an error in XML document (1, 1850).

    Exception from: Net2Toolkit
    Object reference not set to an instance of an object.

    Line (2): "Set processWebService = WebService("WebServiceBrokerImplService").processWebService(XMLWarehouse("anyType"))".

    ReplyDelete