Forum Discussion
Hi Samithak,
You can try using the XMLHTTPRequest object to accomplish your task. Refer to the Preparing SOAP Requests in Scripts ( http://smartbear.com/viewarticle/70743/ ) article to learn how to use it.
Tanya - does that work with JSON? All the ref material seems to refer to XML?
Just that to get the response, he'll probaby have to generate the request himself as well, and it sounds like it's using JSON. I know the MS ServerXMLHTTP object I linked to above handles JSON just fine, despite the name (and lack of any mention of JSON in the docs for it).
- cunderw9 years agoCommunity Hero
I had to do something similar. Here is what worked for me.Hopefully this will help. This is in JScript.
function httpRequest(method, URL) { var XmlHttpRequest = Sys["OleObject"]("MSXML2.ServerXMLHTTP"); XmlHttpRequest.open(method, URL, false); XmlHttpRequest.setRequestHeader("Content-Type", "json"); try { XmlHttpRequest.send(); } catch (err) { Log.Error(err); } //XmlHttpRequest.responseText returns JSON object try { return XmlHttpRequest.responseText; } catch (err) { Log.Error(err); } }
You can then use the following to get the JSON info into an array that you can work with.
var json = JSON.parse(httpRequest("method","http://someurl")); json[i].property.
- samithak9 years agoNew Contributor
Hi Kunderw,
Thanks for the response. This looks like workes for reading the response. But what I really need to see is data I'm posting to server through my GUI is what exactly interpreted and sending to server. I'll give small example.
Application I work with developed using angularjs and one part of it is Canvas control which load a image. And user can annotate on the image. Once image loaded it opens up in between two different fabric canvases and test automation tools cannot access/detect anything separatly on the image. (ex: annotation I have drawn). My senario is, if I change color of the annotation (using color palet) I need to see whether new annotation drawn on the image with correct color.
Solution I thought was reading information from POST request header. I see this information there but donno how to access request header. (NOT the response data)
Please let me know if you guys have any solution.
Thanks
-Samithak
- Colin_McCrae9 years agoCommunity Hero
I'm not sure you can do that from TestComplete.
All the responses relate to using an HTTP object you create yourself. Which, as we've said, you can control the headers of and check the response properties of.
What you want to do is intercept the HTTP object generated and sent by a webpage. Something like Fiddler, you can do this. But if TestComplete has a way of intercepting POST info from a webpage in a similar way, I'm not aware of it.
Canvases are pretty much impossible to do much with. It's just an image file. You may be better pixel sampling the onscreen colours to check if things change colour as and when you expect to. There have been a couple of such pixel sampling routines posted on here recently.
There are a couple of links/examples on here: http://community.smartbear.com/t5/Desktop-Testing/How-do-I-get-forground-and-background-colour-of-a-text-object/m-p/107434
- TanyaYatskovska9 years agoSmartBear Alumni (Retired)
Hi Colin,
W3Schools has several examples of how to read JSON data via XMLHttpRequest:
http://www.w3schools.com/json/json_http.asp
Honestly, I haven’t tried his. However, it’s a good source to start with.
Related Content
- 11 years agokirk_bottomley
- 14 years agoVegasQA
- 2 years agoLRuoc
- 6 years agogenki
- 3 years agomgavan