Thursday, May 21, 2015

Performance Testing - Scripting - Working with Cookies

We received a request to work on ‘X’ application which actually required Facebook login Cred and thru Facebook only we will be able to connect and access the AUT.

The following are the steps provided by dev team earlier to access AUT

1. Open test.applicatioURL.com
2. Click on the FACEBOOK CONNECT Module (left top below the application TITLE)
3. Check the checkbox that says "by check this box you are confirming that you are 13 years or older"
4. Click SIGN IN
5. You will be redirected to Facebook.com. Login with your credentials
6. You will be redirected back to test.applicatioURL.com. Now you are LOGGED into the Application

Issue:
We are not allowed to carryout any Load tests on Facebook, 

Hence access to the application would not be possible and even if we use "facebook" we require unique facebook accounts for N number of concurrent users.

Solution:
After discussing this Problem with dev team they came with a solution
Please find more details as below:

1. Open test.applicatioURL.com
2. Click on the FACEBOOK CONNECT Module (left top below the application TITLE)
3. Check the checkbox that says "by check this box you are confirming that you are 13 years or older"
4. Click SIGN IN
5. You will be redirected to Facebook.com. Login with your credentials
6. You will be redirected back to test.applicatioURL.com. Now you are LOGGED into the Application
7. From the browser, copy the value of the _ko_ama_ cookie under the cokemusic.com domain cookies


 -   We can Use HTTP fox or HTTP Watch Professional to Capture the Cookie.
Lodrunner Script Should look like below

web_add_cookie("_ko_ama_=1f3ca1fabe09f1dc7ee130c851dd5f6540127f53~100002232125235~0~1356333043607; Domain=.applicationDomain.com; Path=/; Max-Age=2147483647; HttpOnly");
               
web_url("POC",
"URL=http://test.applicatioURL.com/ko-ama-api/user/profile/100002232125235",
"TargetFrame=",
"Resource=0",
"RecContentType=application/json",
"Referer=",
                "Snapshot=t1.inf",
                "Mode=HTML",
LAST);

By adding the Cookie the user should be able to access the appliaction and in resposne to the above request the user should get resposne as below:

{"status":"UNLOCKED","vstepImage":null,"photomosaic":{"status":"APPROVED","imageName":"433307
68432d6-7f32308-40dc-bc67-e779547632323401","position":41},"polls":[{"pollId":"63259131c5-d643232b-4314-b
80c-f2a683323296e873","votes":[0,0]},{"pollId":"d405d66b-45e9-4939-beb8-3a7323dd72416e0","votes":
[0,0,0,0,0]},{"pollId":"a09ec8d1-2009-4238-8e26-b41de8ec96c1","votes":[0,0,0,0,0]},{"pollI
d":"83bd3232e252-4429-43232e97-8060-a33ee13232b41a98","votes":[0,0,0]},{"pollId.....
....
...
"},{"fb_id":"103200ss03ff721238688","status":"INVIT
ED"},{"fb_id":"10000368fdds3122155180","status":"INVITED"}],"status":"INVITED","created":"2012-09
-20 11:51:57.13201537","partyId":"81a3232236c1-1487-32234a86-98c53232-bb32323846d838f7"}]}}

Note:
Depending on the User id we use the Cookies and Profile id would change and the resposne will also change and display the current user facebook details