Selenium WebDriver – Architecture

I Try to Simplify as much as possible to understand how the architecture of Selenium formed.
Selenium WebDriver Divided into 3 major divisions
1. Language level Bindings
2. Selenium WebDriver API
3. Drivers
Language Level Bindings
We have a common API that has a common set of commands and we have various bindings for the different languages. So we can see there’s Java, Python, Ruby, etc..There’s also some other bindings and new bindings can be added very easily.
Selenium WebDriver API
Now these bindings communicate with Selenium WebDriver API and this API send the commands taken from language level bindings interpret it and sent it to Respective driver. In short term API contains set of common library which allow sending command to respective drivers.
Drivers
Internet Browser Specific Drivers such as IE, FF, Chrome etc..It works in headless mode which makes, text execution faster. It also contains mobile specific Drivers. The basic idea is each one of these drivers knows how to drive the browser that it corresponds to. For E.g. Chrome Driver knows how to handle the low level details of chrome driver and drive it to do things like clicking the target element, navigating the target page etc...
How it’s working:
You are writing your test in Java using common selenium API and that Java binding is sending commands across this common API. Now on the other end is listening a driver, it interpret those commands and executing them on the actual browser and return result backup using the API.

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: