Skip to main content


Showing posts from November, 2011

Top Security Testing Resources / Tools

A big community called "OWASP - Open Web Application Security Project" releases information about  software vulnerabilities for every year. Also you can learn lot of concepts here.
Here I have done listing of some security testing tools known,

Commercial Tools:
IBM Rational AppScan
HP QA Inspect
HP WebInspect
HP Fortify
Cenzic Hailstorm

OpenSource Tools:
WebScarab by OWASP community
SkipFish - by Google

Some good Resources / Blogs / Sites for Selenium Users

Here I have listed out some good blogs and sites by extensive selenium automation users. Hope these will help you a lot. - by NirajKumar  - by Naga/Mathu - by Farheen Khan - Amit Vibhuti

Sauce Labs and BrowserMob are companies doing cloud and extensive selenium automation services, products, etc

Cedric Beust - creator of the TestNG Java testing framework. - by Samit Badle, Created many Selenium IDE Plug-Ins

Available Colud Testing: 1. SauceLabs 2. Soasta 3. BrowserMob 4. etc.
Selenium Testing Products: 1. Twist by ThoughtWorks
2. TestMaker by PushToTest 3. Element34 company providing selenium testing services, etc.

Selenium Grid -  http://www…

Selenium - waitForCondition with JavaScript Expressions

Selenium provides select method to select an item/option from drop-down lists and comboboxes. But this will work for simple listboxes only. For complex comboboxes like textbox with image, clicking the image will open drop-down list will not support normal methods. Here I am listing out different ways to handle select boxes. Thanks to bloggers as I read these from one and more blogs.

Consider the following example where there are two drop-downs, one for the states and the other for counties.
The county drop-down is populated based on the state selection.
You can see in the site above, when the state is selected, a spinner shows up for a few seconds before the county drop-down is populated. 
Here we are using waitForCondition as it allows to mention explicitly TIMEOUT whereas selenium provided waitFor allows only default TIMEOUT value.

1. Dependent drop-down Lists using waitForCondition
Using waitForCondition and some JavaScript, we wait until display style attribute changes to ‘none…

Selenium - Drag and Drop Operation

The inbuilt dragAndDrop function provided by selenium RC classes will do the expected operation well easily. Some times its difficult to do drag and drop operations like drop on particular element, etc. Here is the approach.

1. Drag an element to drop on to another element:
driver.get("myURL"); var from = driver.findElement(By.xpath("fromElement")); var to = driver.findElement(By.xpath("toElement")); new Actions(driver).dragAndDrop(from, to).build().perform();
2. Drag an element to an offset:
driver.get("myURL"); var dragElement = browser.findElement("ElementToDrag")); new Actions(driver).dragAndDropBy(dragElement , 200, 10).build().perform();

Selenium - Handle Iframes/Frames easily

Hi all,
Here I am going to list out ways to handle iFrames parts in selenium automation as I read from some sites.

//Gmail Body is an iframe. Here we are writing content to body of new mail in selenium var bodytext="Sample Body Text for Testing";   var iframe_locator = "css=table:contains('Subject:')+*  iframe\"; var iframe_body = selenium.browserbot.findElement(iframe_locator).contentWindow.document.body; if (browserVersion.isChrome) {       iframe_body.textContent=bodytext; }  else if(browserVersion.isIE) {   iframe_body.innerText=bodytext; }

//Switch to the frame - use index/name driver.switchTo().frame("frameName"); //Also you can use like 

// Do your operations in frame

Selenium Rare Tips - Part II

1. Get Browser Name, Version and Environment Details
Java Script Expressions which you can use by Selenium.getEval to get the values.

navigator.appCodeName//For Browser Name navigator.appVersion//For Browser Version navigator.userAgent//For both details navigator.appName//For Browser Name navigator.cookieEnabled//Cookie enabled or not navigator.platform//OS

2. Get Current URL

3. Scroll Bar Position

Actual Width/Height of element:(Excluding ScrollBar) selenium.browserbot.getCurrentWindow().document.getElementByid('css#id').clientWidth selenium.browserbot.getCurrentWindow().document.getElementByid('css#id').clientHeight Max Scroll Position: scrollWidth - clientWidth    //Max Horizontal Scroll Position

Add Custom functions to Selenium

We can add custom functions to selenium or extend your selenium jar functions as you want. We can do this in 2 ways.

1. Extending selenium-browserbot.js and selenium-api.js
     a. Extract your selenium-server-standalone-xxx.jar to temp folder.
     b. Find the files selenium-browserbot.js and selenium-api.js inside core\scripts\ folder.
     c. Add your custom function to class BrowserBot like below in selenium-browserbot.js.

 BrowserBot.prototype.yourFunctionName= function(){ //code here }
     d. Now add your function to class selenium to expose Selenium API like

selenium.prototype.yourFunctionName= function(){ returnthis.browserbot.youFunctionName(); }
     e. Thats all. Re-bundle your JAR file with updated files. Your Selenium-Server JAR file  is ready with your custom functions.

Here is the example code:

BrowserBot.prototype.getAllRadios= function(){        var elements =this.getDocument().getElementsByTagName('input');         var result =[];

Selenium Rare Tips - Part I

Hi all,
Here I am going to list out some rare and useful tips for selenium users.

1. Start/Shutdown SeleniumServer in proper way
publicstaticvoid startSeleniumServer()throwsException{ try{ ServerSocket serverSocket =newServerSocket(RemoteControlConfiguration.DEFAULT_PORT);         serverSocket.close(); //Server not up, start it try{                          RemoteControlConfiguration rcc =new RemoteControlConfiguration();                          rcc.setPort(RemoteControlConfiguration.DEFAULT_PORT);                          server =new SeleniumServer(false, rcc);