Rock & Roll With Http Level Testing
Article written by Sreenivas Mothukuru
In continuation to my previous topic (My approach towards automation)
There are many tools available on web to test at http level. However, I explored Web Inject tool and found the tool very handy & simple to impliment http level testing.
Follow below steps to run http level tests to check form validations and apache redirections for http://www.blogger.com/ web site.
1) Download “webinject-1.41.win32.zip - MS Windows Executable + Source Code” from http://www.webinject.org/download.html location).
2) Un-zip “webinject-1.41.win32.zip” and copy folder to some drive/location.
3) In Config.xml (within Web Inject folder), replace entire content with
********************************************************
<testcasefile>sampleTest.xml</testcasefile>
********************************************************
<testcasefile>sampleTest.xml</testcasefile>
********************************************************
4) Create a file named “sampleTest.xml” (within Web Inject folder) and copy below content to the file.
********************************************************
<testcases repeat="1"><case
id="1"
description1="Accessing www.blogger.com/ web site"
description2="User is seen redirected to another page (i.e. www.blogger.com/home)"
method="get"
url="http://www.blogger.com/"
verifyresponsecode="302"
/>
<case
id="2"
description1="Accessing www.blogger.com/home"
description2="User is seen redirected to https://www.google.com/accounts/ServiceLogin? ... "
method="get"
url="http://www.blogger.com/home"
verifyresponsecode="302"
/>
<case
id="3"
description1="Accessing https://www.google.com/accounts/ServiceLogin? ..."
method="get"
url="https://www.google.com/accounts/ServiceLogin?service=blogger&passive=1209600&continue=http://www.blogger.com/home&followup=http://www.blogger.com/home&"
verifyresponsecode="200"
verifyresponse="Email"
verifyresponse1="Password"
verifyresponse2="Don't have a Google Account?"
/>
<case
id="4"
description1="Form validation - both Email & Password fields left blank"
method="post"
url="https://www.google.com/accounts/ServiceLoginAuth"
postbody="ltmpl=start&pstMsg=1&dnConn=https%3A%2F%2Faccounts.youtube.com&continue=http%3A%2F%2Fwww.blogger.com%2Fhome&followup=http%3A%2F%2Fwww.blogger.com%2Fhome&service=blogger&dsh=2093325602420315311<mpl=start<mpl=start&timeStmp=&secTok=&GALX=lfJvJ5-NTRI&Email=&Passwd=&PersistentCookie=yes&rmShown=1&signIn=Sign+in&asts="
verifyresponsecode="200"
verifyresponse="Enter your email address."
/>
<case
id="5"
description1="Form validation - Password field left blank"
method="post"
url="https://www.google.com/accounts/ServiceLoginAuth"
postbody="ltmpl=start&pstMsg=1&dnConn=https%3A%2F%2Faccounts.youtube.com&continue=http%3A%2F%2Fwww.blogger.com%2Fhome&followup=http%3A%2F%2Fwww.blogger.com%2Fhome&service=blogger&dsh=-5106055381980639771<mpl=start<mpl=start&timeStmp=&secTok=&GALX=lfJvJ5-NTRI&Email=heysreeni&Passwd=&PersistentCookie=yes&rmShown=1&signIn=Sign+in&asts="
verifyresponsecode="200"
verifyresponse="Enter your password"
/>
<case description1="Form validation - Password field left blank"
method="post"
url="https://www.google.com/accounts/ServiceLoginAuth"
postbody="ltmpl=start&pstMsg=1&dnConn=https%3A%2F%2Faccounts.youtube.com&continue=http%3A%2F%2Fwww.blogger.com%2Fhome&followup=http%3A%2F%2Fwww.blogger.com%2Fhome&service=blogger&dsh=-5106055381980639771<mpl=start<mpl=start&timeStmp=&secTok=&GALX=lfJvJ5-NTRI&Email=heysreeni&Passwd=&PersistentCookie=yes&rmShown=1&signIn=Sign+in&asts="
verifyresponsecode="200"
verifyresponse="Enter your password"
/>
id="6"
description1="Form validation - Invalid user name and password field"
method="post"
url="https://www.google.com/accounts/ServiceLoginAuth"
postbody="ltmpl=start&pstMsg=1&dnConn=https%3A%2F%2Faccounts.youtube.com&continue=http%3A%2F%2Fwww.blogger.com%2Fhome&followup=http%3A%2F%2Fwww.blogger.com%2Fhome&service=blogger&dsh=-5106055381980639771<mpl=start<mpl=start&timeStmp=&secTok=&GALX=lfJvJ5-NTRI&Email=heysreeni&Passwd=dsfsfsdfsd&PersistentCookie=yes&rmShown=1&signIn=Sign+in&asts="
verifyresponsecode="200"
verifyresponse="The username or password you entered is incorrect"
/>
</testcases>
********************************************************
5) Test Cases 1, 2 & 3 validate apache redirections and Test Cases 4, 5 & 6 validate form validations for Blogger site.
5) Test Cases 1, 2 & 3 validate apache redirections and Test Cases 4, 5 & 6 validate form validations for Blogger site.
6) To open Web Inject client application double click on “webinjectgui.exe” file (within Web Inject folder).
7) Now, click on “Run” button.
8) That’s all; you can see http tests running on the same window with results. You can monitor the response time while tests are running. Detailed test results can be viewed at “results.html” file (within Web Inject folder). Also, select “Response Timer Output” checkbox to know the response time for each http request.
Observations (form validation & apache redirection tests for blogger.com):
- "sampleTest.xml" http level test script took ~11 seconds to execute all cases.
- same tests at browser level (using Selenium) took ~25 seconds to execute all cases.
Note:
- Follow below links to know more about http level automation using Web Inject.
- Example mentioned in this blog is very basic and trivial. To make the example easy to understand I didn't use methods provided by Web Inject. Http tests can be well maintained if Test Engineers efficiently use all available WebInject methods.
------------------------------------------------------------------------------------------------
Feel free to ping me / email me if you have any questions regarding the usage of Web Inject tool
------------------------------------------------------------------------------------------------
Hi Srinivas, First of all thanks for nice post, but can you please explain how did you get postbody ? in post testcase.
ReplyDeleteDeepak
Deepak,
ReplyDeleteUsing Firebug (Firefox add-on) tool we can check requests and responses at browser level.
Follow below steps to see request and response headers for "Get" and "Post" requests.
1) Go to https://addons.mozilla.org/en-US/firefox/
2) Search for “firebug” add-on.
3) Select "firebug" from search results and add it to Firefox browser.
4) After installing Firebug on Firefox restart (close and open) Firefox browser.
5) Click on “Tools” (Alt + T), select “Firebug” and click on “Open Firebug” or Select 'F12'.
6) Select “Net” tab (click on “All”).
7) Access http://www.blogger.com/home URL.
8) Provide Email, password and click on “Sign in” button (Now check request and responses using firebug).
9) You can see post request in Firebug window (i.e. https://accounts.google.com/ServiceLoginAuth).
10) Expand (Click on ‘+’) Post request, click on “Post”, scroll down and look at the “Source” section. You can find all “Post” parameters.
Feel free to ping me if you need any help / if you have any questions.
Thanks,
Sreenivas
Hi Sreenivas,
ReplyDeleteThanks for the reply, but i followed your instructions but still cannot get this to work ??. I am testing this on our moodle website. I can supply you with test login and password if you have time could you please test this process for me ?.
Thanks in advance.
Deepak
Deepak,
ReplyDeleteShare test login and password with the URL information (i.e. http://www.moodle.org). I'll work on it when I find some free time.
Thanks,
Sreenivas
Deepak,
ReplyDeleteLooks like your site (http://www.moodle.org) is pretty much simple to automate at http level. Send user name and password to my email account (heysreeni@gmail.com). I'll get back to you with test scripts.
Regards,
Sreenivas
I will email you the details on your email, but it is now moodle.org it is moodle hosted on our environment.
ReplyDeleteThanks for your help.
Deepak
Deepak,
ReplyDeleteReplied to your email with solution.
-Sreenivas
Thanks a lot for your help it worked like a charm, You are a true champion. Please let me know if there is any way i can help you.
ReplyDeleteDeepak
My pleasure :)
ReplyDeleteDeepak,
ReplyDeleteCheck this ...
www.mothukurusreenivas.com/2011/12/ever-tried-adding-2k-comments-to.html
-Sreenivas