Selenium Automation Framework Design


To design a framework we need to concentrate on the following factors.
1. We need to create UI Map
2. Libraries for UI objects.
3. Design classes based on application under test.
4. Plan for test execution approach to minimize the time.
5. Design report generation.
6. Prepare a Step table and step suite.
7. Prepare a Data set where ever needed
8. Design Keyword Driven action fixtures
9. Design and develop the psudo code.

Simple Startup in Web Driver

Web driver is a java interface which is having lot of implementing classes and functions which we can refer from javadocs in selenium official site.

Download latest java client version from  http://seleniumhq.org/download/. Its a zip pack, Unzip and go to eclipse Create new java project and right click on java project and select Build Path ---> Configure build path Click "Add External Jars" and select all the jar under the unzipped folder. Then click OK.

Selenium IDE - parametrization

Parametrization is one of the key area in Test automation. We have to design and develop the maximum combination of test data to give as input. This is one of the main reason we are moving to RC. But it can be possible in Selenium IDE too.

Steps to invoke the data file in to Selenium IDE

Shutdown Selenium Server from browser URL

Selenium server operates a web server under Jetty it can receive commands via http through browsers.
The following URL will be used to shut down the server.
If we want to leave the server running and just close down the current session we could issue the following URL in a browser.

Java Script Tweaks

Java Script get Current Date:
Some of the Calender Controls couldn't be handled by Selenium.

This will return the Current Date as ""MM/DD/YYYY"
javascript{var currentDate = new Date(); var month = currentDate.getMonth() + 1; if (month < 10) { month = "0" + month }; var day = currentDate.getDate(); if (day < 10) { day = "0" + day }; var year = currentDate.getFullYear(); curentDate=(month + "/" + day + "/" + year);}

JUnit Syntax:
String t1 = selenium.getExpression(selenium.getEval("var currentDate = new Date(); var month = currentDate.getMonth() + 1; if (month < 10) { month = \"0\" + month }; var day = currentDate.getDate(); if (day < 10) { day = \"0\" + day }; var year = currentDate.getFullYear(); curentDate=(month + \"/\" + day + \"/\" + year);"));
selenium.type("StartDate", t1);

Selenium Data Driven using Properties files

We need to get value from a data source for different purpose here listed some of the basics.
  • GUI Components
  • Test Data
  • URLs
GUI Components:
If we have mapped the GUI components with a value we can change the value in a single place rather changing in whole script where ever we used.
Test Data:
We can pre designed test data with all available or maximum possible combination of  user input.
URLs:

Sample Template - Test Scenario