Thursday, May 31, 2012

How to Test Facebook App using selenium

I had given a lot of thought for building test cases for the FB app .
Major areas for testing were -
a) New user registration
b) Permission acceptance flow
c) Other features of the app. but most of which should be manually tested.

Enter, Selenium . It simple automate browsers.  Its really simple . I did the following

1) Fired firefox. Added Selenium IDE Plugin . It basically records user actions , initially in HTML which later can be exported to python or other supporting laguage.

2) After step 1, half work is already done   :)

3)  Now on to FB part. Here I was trying to automate New User Registration Flow. Here I needed a new test user everytime I run the script.

Enter , Facebook's Test User Api.
a) First get App Access Token
b) Then get a new test user credentials

4) Now include this flow in your test case, Call the script to get test user credentials, and login and go to app, and viola, Test Case Completed.

5) There is one small thing though, :) , the python exported test case gave error on the action when it tries to select frame of the app. Here we can use switch_to_frame method.

Rest all was a piece of Cake.
//Edit - Not exactly piece of cake, cause the test cases are performing a bit weird.  :)

Monday, May 21, 2012

Session problems in canvas FB app on IE

While building Shine App , I learnt a number of things . One of them is that IE doesnt store third party cookies . Because of this IE doesnt store session cookies of any app .

Particularly in my app, I needed sessions. Hence , on not finding one , I assumed session is lost and I redirected the user for re-authentication.

Solution of this is passing on specific headers, named P3P and giving them value as
CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"

I still havent figured out the meaning of these . Ill learn more about it in future.
 Web Development is definitely fun :)