cURL and HAR for Web application testing
Marcee last edited by user
I found Web browsers provides information that could be somehow useful for a tester/dev:
- HAR (HTTP ARchive) files that can be later viewed with HAR viewers.
cURL command, e.g., here is what I got when doing "Copy as cURL" for this web page:
curl 'https://sqa.stackexchange.com/' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Host: sqa.stackexchange.com' -H 'Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8' -H 'Referer: https://sqa.stackexchange.com/' -H 'Cookie: __qca=P0-1782664706-1363204143275; sgt=id=372cfe23-66cf-4686-bd71-3fd115e4f32a; __utma=27693923.46027841.1363204138.1379233083.1379250315.372; __utmb=27693922.214.171.1249250315; __utmc=27693923; __utmz=27693923.1375130388.204.7.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); sqauser=t=WZvUS8s6IEWP&s=T2hKXHEgzkC7' -H 'Connection: keep-alive' -H 'If-Modified-Since: Sun, 15 Sep 2013 13:46:59 GMT' --compressed
I usually include URLs, HTTP requests and responses (whole, or only header or body with JSON). So I wonder if cURL and HAR are better than that and if so, then how. Particularly:
- Does it make sense to attach them to a bug report? In what problems they can be useful?
- How cURL command is better from simple URL or JSON request to reproduce the issue? Did cURL help you isolate any defect or understand the problem better than HTTP Request? It seems to me to be the same, just sending a request from command line seems more straightforward.
- Is HAR file useful only to understand performance problems? If so, then how? If no, then also how?
Bogopo last edited by user
In what problems they can be useful?
cURL's output is the HTTP response, so I think they're equivalent. You might choose to capture the output with cURL if capturing via the browser requires a lot of typing and clicking.
How cURL command is better from simple URL or JSON request to reproduce the issue? Did cURL help you isolate any defect or understand the problem better than HTTP Request? It seems to me to be the same, just sending a request from command line seems more straightforward.
Is HAR file useful only to understand performance problems? If so, then how? If no, then also how?
The HAR captures traffic going in both directions, i.e. the requests and the responses. If your developers or testers believe that reproducing a problem requires specifying things to that level of detail (e.g. instead of instructions in terms of clicking and typing), then the HAR is a good way to go. It's easy enough to read them as regular text files, and there are fancy viewers for them too.