Saturday, 20 October 2012

Selenium Web Driver to test websites

In this post I will write how to use selenium web driver to test the websites.Selenium  web driver allows us to drive the browser from the code supporting many languages like java , python etc.While it takes a little setup for chrome and ie,it works with firefox without any setup.I am using java to drive firefox browser.

The main goal of this post is to share code on how to design the test suite to make the code most reusable and also to make the testing reliable irrespective of user's connection speed.On to the design now :

The basic approach to design a test suite should be to create methods which automate elementary tasks and then to use these methods from the testing class and assert the results.This way the code developed for automating elementary tasks can be used by any potential testing client.For example : for website testing, tasks like logging in,logout,using various features of site like create post in blogger etc. can be put in a common class.

The test suite I developed is to test a salesforce app , so I will provide methods which helps doing login,selecting apps from the top right,selecting tabs,asserting page title etc.

Also I have overridden the selenium web driver's default methods like findElement() and some others to wait them for given time for page to load before throwing element not found kind of exceptions resulting from incomplete page load.

Please set the variable TIMEOUT according to connection speed.The logic behind waiting till timeout is the recursive call of the methods each after 1 sec.The methods exit after TIMEOUT if the desired elements are not found.

Monday, 3 September 2012

salesforce lead conversion


This application allows user to search leads based on a keyword and giving fields to search in. User can then go to details page of returned leads, can select multiple leads and then can convert selected leads by providing an account name.  The Outcome will be an account, a contact for each lead and an opportunity for each lead. After successful conversion user will be redirected to newly created account’s detail page.

Video Url:

you can install the unmanaged package from :

App uses one visual force page and one controller :

VisualForce Page :



Controller :

Salesforce Mashup with google maps

This app helps user to plot  sales on the google map.The sales to be plotted can be filtered based on various criteria like location,size,type,date etc.Clicking on a sale on the map redirects to the corresponding account.
Final application looks like this :
you can install the unmanaged apex package from  here :
https://login.salesforce.com/packaging/installPackage.apexp?p0=04t90000000Pyoa

The app uses only one visual force page and one controller

Visual Force page :


Controller :

Monday, 4 June 2012

Country database android app

we created this app for bitsmun . The app has database for many countries which includes various country details like area,population,military,politics,constitution taken from Cia-World factbook . This is an Html5 app created using phonegap. you may find the source code  at http://munappbits.appspot.com/ by viewing the source of webpage.

Android installer :  https://docs.google.com/open?id=0Bxag-fuMuJ3-RmNjMzlKcFZITUk

let me know in comments ,  if you want the source code of phonegap project and I will upload.

Sunday, 29 April 2012

Dynamic SQL query when number of fields in where clause in not known

suppose we have a front end where user can select different filters to narrow down the query results.In this case it is not already known which all fields user will select.
A dynamic query for this case can be constructed using this trick:

here fieldNames is the array containing names of all filters and fields is the array containing values provided by user.

String query="SELECT * from tableName";
String prefix=" WHERE ";  //notice spaces before and after WHERE
for(int i=0;i<fields.length;i++){
      if(fields(i)!=null)
        {query=query+prefix+fieldNames(i)+" = "+fields(i);
          prefix=" OR "    //notice spaces before and after OR
         }
}

Saturday, 28 April 2012

Force.com Eclipse plugin installation problem

Installation fails with error 'Md5 hash not as expected'
original error message :


An error occurred while collecting items to be installed session context was:(profile=SDKProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=). Problems downloading artifact: osgi.bundle,com.salesforce.ide.api,23.0.2.201201091635. MD5 hash is not as expected. Expected: 97a6329f82c422a61e9b1bc28be7cace and found ef8b1c2b63c7d04acaa6bf41f4b8570c.


this happens due to corrupted download of jars by eclipse.To fix the problem follow these steps:
1. download all jars manually from
    http://www.adnsandbox.com/tools/ide/install/features/ and
    http://www.adnsandbox.com/tools/ide/install/plugins/
   you can use firefox plugin 'download them all' to download all links in one click.
2. put them in /features/ and /plugins/ directory of eclipse
3.run plugin installation again as you would do normally.It won't download the jars again and it will work without error.

original post:
http://stackoverflow.com/a/9823562/1219463

Tuesday, 29 November 2011

8 Puzzle,cool android game

Here is a very basic puzzle created by me for android devices.Feel free to download and install..

Download apk(android executable)

Download source code