Forum Discussion
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.
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,
I agree with Colin – perhaps you may need to consider implementing a script to calculate the color of the background (based on the number of pixels with the same color). One more idea is to try using another SmartBear product – LoadComplete. It can record the HTTP traffic. So, you always check if your app sends the requests you expect.
Related Content
- 11 years agokirk_bottomley
- 14 years agoVegasQA
- 2 years agoLRuoc
- 6 years agogenki
- 3 years agomgavan
Recent Discussions
- 8 hours agosimonaferrara
- 17 hours agoSubhraDas