Tuesday, September 1, 2009

Automatic Birthday Scrap to Orkut Friends Using WATiN

Introduction

By using this application, Orkut users can send birthday wishes scrap to their friends without fail and even without logging into Orkut site. It is just like eliminating human interaction with website while sending birthday scrap to Orkut friends without missing nearest, dearest friend’s birthdays. Just by running this application, you can finish this work within seconds. You can set a time to run this application on a daily basis at a predefined time.

Implementation

You have to add this application in your control panel scheduler with some predefined time. And at the predefined time, this application will run and will do all the operations that you are supposed to do in Orkut while sending birthday scrap to your friend. :) If we run this console application, we will see an Internet Explorer browser opening and automating the entire manual process. Isn't that cool? :)

Background

I remember those days when I used to login in to Orkut to check for friends' birthdays. if it’s there, then I used to scrap them with best wishes. But the most difficult part is to remember friends' birthdays (that’s my experience). Suppose we were not able to open Orkut on a particular day (that happens to be my friend's birthday), then it would be like we missed wishing friends. If the next day, we get a chance to login to Orkut, then we need to send wishes with a belated word. :( Then one day I thought we need to have an application which can remove our painful situation. The application should be in my control, in my hand and can take care of all this stuff. It’s like a computer is working in place of me. After struggling for a few hours with my thinking, ideas and knowledge, I came up with an idea that I could develop an application which could do as per my thinking. That’s great. :) So, I would love to present an application which is a replica of my knowledge/idea in C#, .NET and WATIN.

What is WATiN

WATIN, pronounced "What-in", is an acronym standing for "Web Application Testing in .NET". WATiN is a toolkit used to automate browser-based tests during web application development. This automated test tool uses the C# language to drive the Internet Explorer web browser. To know more about WATiN tool kit, please refer to this link.

Using the Code

To interact with Orkut web site, I have used WATIN tool as API interaction between my code and Orkut web site. For programming language, I used C# with .NET 2.0 and I hope that you guys are familiar with WATiN. I would prefer to explain the code line by line so that we will get an idea about how we can use WATiN for automation purposes as well as for other purposes like Interacting with other web sites just like an API.

Flow Chart (http://jawedm.blogspot.com)

  1. Open a new instance of Internet Explorer (can be in visible mode).
  2. Go to http://www.orkut.com/.
  3. Login with predefined email id and password.
  4. Move to Login User home page.
  5. Check if any friends' birthday falls today, if yes, then go to step 6, else step 10
  6. Click at link LEAVE a SCRAP and go to selected friend’s scrap book.
  7. Type predefined BIRTHDAY MESSAGE/WISHES and post that scrap.
  8. Move back to Login User home web page.
  9. Further check for the next birthday date, if it falls today, repeat steps 6 to 8.
  10. Click on logout link of Orkut web site.
  11. On successful logout, close the browser.

Now let’s put the above steps in code.

  1. Open Visual Studio and select New project as Console application. (I assume that you are familiar with Visual Studio 2005)
  2. Go to ADD reference and add WATiN.core.dll and Nunitframework.dll in your project.
  3. ADD below namespace in your code file to access WATiN classes and method.

See full detail: http://www.codeproject.com/KB/applications/OrkutBirthdayScrap.aspx

No comments: