Showing posts with label Quick Test. Show all posts
Showing posts with label Quick Test. Show all posts

Friday, August 28, 2009

Testing WebServices using QTP

It is tricky but extremely simple to test web services using QuickTest. I was given this task of creating a framework for testing a particular set of Use Cases which had to be done using services as no UI was available. I started with using the Web Services wizard to pass input parameters and get the output data sets or values. Later I found that the same could not be extended as the Object Repository holds the Webservice name with wsdl path and port name. This forced me think differently to make every parameter configurable.Let's first know few points:

1) SOAP : SOAP, which stands for Simple Object Access Protocol, is defined by the SOAP standard available at http://www.w3.org/TR/SOAP. The SOAP protocol defines the format of standard XML messages that are used to communicate among systems. Because the message format is standardized and based on the XML standard, SOAP can be used to communicate among multiple computer architectures, languages, and operating systems. SOAP enables a new class of applications called Web services, which expose services in a standard way so that application developers can create new applications by putting together services from many different sources on the Web.There are four main areas covered by the SOAP specification: a required SOAP Envelope format that defines what the envelope that surrounds the XML content of a SOAP message must look like; an optional set of encoding rules that defines how language types are mapped to XML in a SOAP message (since this is defined in section 5 of the specification, it is referred to as "section 5 encoding"); an optional RPC format that defines how function calls are expressed in SOAP messages; and an HTTP binding that defines how SOAP messages may be exchanged through HTTP.

2) WSDL: WSDL stands for Web Service Description Language. In order to successfully call a Web service you will need to know how to get to the service, what operations the service supports, what parameters the service expects, and what the service returns. WSDL provides all of this information in an XML document that can be read or machine-processed.
The next necessary steps to call this SOAP method using the high-level SOAP API are:create a SOAPClient objectinitialize the SOAPClient object with the WSDL fileand call the method
Below is a snippet for same:
Set oSOAPClient = CreateObject("MSSOAP.SoapClient")

oSOAPClient.mssoapinit wsdl_path, service_name, port_name

oSOAPClient.Methodname param1, param2, return_param1

Above snippet might give error while running on windows 2003 of ActiveX component. To correct it download the SOAP Tool kit from msdn version 3.0 and install it and following change to first line of script:

Set oSOAPClient = CreateObject("MSSOAP.SoapClient30")


Reply back to me if you need any clarifications or updates.

Tuesday, March 31, 2009

QTP scripts bulk update.

We were caught in an extremely awkward situation few days back (I wonder why we always run into such situations :) ) wherein we upgraded our HP Quality Center and HP QTP to 10.0 which is their recent release. QTP 10.0 scripts were also in QC.
Before the upgrade took place we were running on QTP 9.2. We had a common vbscript for each Test Case in QC which used to call reusable actions saved at different location in QC. We also had associated those reusable actions. But after upgrade all our efforts were drained and we were left in a jeopardy where we could not even move back to 9.2 as much work had been done on QC front after the upgrade. The upgrade was done on live system without even checking on test systems whether it works or not. Management was to be blamed for it. Anyways, after the upgrade this association was lost and i was roped in to clear the debris and bring back the whole system on track.
After doing some research i came up with this unique update technique to get all the scripts updated automatically. I looked in all files which get saved when we save a QTP script and found that the 'Script.mts' file holds the actual text displayed when we open any script. I thought of updating the RunAction statement in this text with LoadAndRunAction statement. The parameters required for this new statement were different than from previous one which led to introduction of additional line of code which would call a new function and a additional vbs function. Our probelm was resolved and we were back to routine execution but the issue gave me nightmares.
Step 1:
Step 2:
Step 3:
Step 4:
Step 5: