Forum Discussion
- NisHeraValued Contributor
- Colin_McCraeCommunity Hero
I just use an ServerXMLHTTP object. (https://msdn.microsoft.com/en-us/library/ms766431(v=vs.85).aspx)
This is just for sending to a RESTful API during tests. There are limits to what you can do and check with it. But if you just need to drive things via an API and interpret the responses, it does the job fine.
NisHera - I've been using the Requests library for Python in something outside of TestComplete and it is indeed a very nice HTTP handler. Makes things VERY simple to use. Only drawback I've found is that by making everything so simple, it sometimes goes a little too far. If a request fails, it seems to automatically try again - which I don't always want. And it can hit the usual problem in Python where a connection can get "stuck" open (although his happens a LOT more using urllib2). But I wrap the whole thing in an Eventlet to stop a connection getting stuck permanently. That, and the default logging level for the library is set way too high. But that's easy to turn down. (Just make sure you also set the same level for the urllib3 library - which it uses - as it's that that generates a lot of the unwanted "info" level log messages.)
- ykrrishnaOccasional Contributor
NisHeraColin_McCraeAlexKaraskevin_kapell
Thanks for the reply.
I do have imported the required libraries earlier but I am getting a timeout error.
Is it ok if I ask for the code samples for how you are handling your request and response from the URLs ? As I am also working on REST I hope that will be a great help
Thanks All
- Colin_McCraeCommunity Hero
Mine is VBScript ...
' Set up the POST Set json_object = CreateObject("MSXML2.ServerXMLHTTP") json_object.open "POST", <URL-OF-ENDPOINT>, False json_object.setRequestHeader "Content-Type", "application/json" ' Send the JSON json_object.send <JSON-DATA> ' Grab the reply code from the server reply = json_object.status
I use it as send only. (Hence always using "POST") The response is a simple response code. Which I normally expect to be a 200. And of course, it triggers some actions from the service it hits which are reflected on the website I run the tests against.
With a "GET" request, you get a JSON/XML blob in the response which you can parse.
<URL-OF-ENDPOINT> is the API endpoint you want to hit.
<JSON-DATA> is a string I build in code. It's only relevant to the application I'm testing obviously.
Pretty straightforward. More reading here: https://msdn.microsoft.com/en-us/library/ms766431(v=vs.85).aspx
- kevin_kapellFrequent Contributor
For API Testing you can use SOUPUI but if you do not have a tool already consider using Postman & Newman (both free). Newman is a command line interface for running Postman collections. TestComplete can trigger the Newman script.
- AlexKarasChampion Level 3
Hi,
Generally speaking, SoapUI better fits REST testing than TestComplete, though https://community.smartbear.com/t5/TestComplete-Functional-Web/TestComplete-support-for-automating-REST-API/td-p/110066 will provide you with the ideas how to implement REST testing with TestComplete.
Related Content
Recent Discussions
- 4 days ago
- 4 days ago