Skip to main content

Posts

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 BurpSuite 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. http://automationtricks.blogspot.com  - by NirajKumar http://www.theautomatedtester.co.uk/ http://testerinyou.blogspot.com   - by Naga/Mathu http://seleniumready.blogspot.com  - by Farheen Khan http://seleniumdeal.blogspot.com/  - Amit Vibhuti http://seleniumexamples.com/blog Sauce Labs and BrowserMob are companies doing cloud and extensive selenium automation services, products, etc http://saucelabs.com/blog http://blog.browsermob.com http://testingbot.com/ Cedric Beust -  creator of the TestNG Java testing framework. http://beust.com/weblog/ http://blog.reallysimplethoughts.com/  - by Samit Badle, Created many Selenium IDE Plug-Ins Available Colud Testing: 1. SauceLabs 2. Soasta 3. BrowserMob 4. CloudTesting.com  etc. Selenium Testing Products: 1. Twist by ThoughtWorks 2.  TestMaker by  PushToTest 3. Element34 company providi

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. Exmaples: 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 attribut

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 ( By. id ( "ElementToDrag" ) ) ; new Actions ( driver ) . dragAndDropBy ( dragElement ,  200 ,  10 ) . build ( ) . perform ( ) ;

Selenium - Handle JavaScript Alert and Confirmation boxes

Confirmation boxes  and Alerts are handled in same way in selenium. var alert  =  driver. switchTo ( ) . alert ( ) ; alert. dismiss ( ) ;    //Click Cancel or Close window operation alert. accept ( ) ;     //Click ok Handle Confirmation boxes via JavaScript, driver. executeScript ( "window.confirm = function(msg){return true;};" ) ;

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. Example-1: //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; } Example-2: //Switch to the frame - use index/name driver. switchTo ( ) . frame ( "frameName" ) ;   //Also you can use like  SwitchTo.Frame(relative=up) SwitchTo.Frame(relative=top) // Do your operations in frame   //Switch back to the parent window driver. switchTo ( ) . defaultContent ( ) ;

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 selenium.getLocation ( ) 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 scrollHeight - clientHeight  //Max Vertical Scroll Position Current Scroll Position: scrollLeft scrollTop If you are usin

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 ( )   {                return   this . 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   =  fun

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 public   static   void  startSeleniumServer ( )   throws   Exception   {           try   {          ServerSocket  serverSocket  =   new   ServerSocket ( 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 ) ;                       }   catch   ( Exception  e )   {                          System . err . println ( "Could not create Selenium Server because of: "   +  e. getMessage ( ) ) ;                         e. printStackTrace ( ) ;                  }