Skip to main content

Posts

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 . youFunctionN...

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 ( Remo...

Maintain Locators - Selenium Automation Projects

Automating your application is easy on the way to reach your goal in your selenium tests. But give me answers to below questions or answer yourself. 1. Is it readable? 2. Is it easily modifiable while your script grows? 3. Is it easily identifiable? 4. Can anybody edit your locator? etc.... For all these questions, your answer might be a big NO.To solve this prob, here is the approach. Maintaining Locators: Always maintain your locators in a single file which is supported by your script driven language like below. Java   ---  you have .properties file Python  --- Config parser or dictionaries C#  --- .config file Ruby  --- YAML  file So maintain your locators in a single file and edit whenever you want like QTP Object Repository. Your file should contain your locators like this. PageName.ElementName=ElementLocatorString Ex: locators.properties file # Here  registration  is my page and firstname is element on registration page....