Selenium Components-Selenium IDE and Webdriver

Selenium Components

Selenium has two components viz. Selenium WebDriver and Selenium IDE. Lets take a closer look at each of them.

Selenium IDE

It is available as a Firefox addon that one can use to simply record the scripts to run and/or export them for later run. The IDE can run/play the earlier recorded scripts. If the goal is to quickly create an individual and independent scripts this tool is perfect to use.

Below is a normal procedure to use Selenium IDE:

  • After installing the Selenium IDE into Firefox simply open up the IDE window. You should see the baseUrl in the baseUrl field in the IDE
  • By default the IDE starts recording the script. Now simply openup the web application and perform any task you want.
  • When finished the task, click on the recording button(red button on right) to stop the recording
  • Now the the same task can be re run by clicking the (green)play test case button
  • The recorded script can be exported for later use from the “File” menu using the “Export Test Case” option in various programming languages
  • Users can play around with the various options provided by the IDE for more customization

Selenium WebDriver

If the goal is to create a ralatively larger set of robust, complex and well organized test cases or suits to automate the tasks in the web application then the Selenium WebDriver is the way to go.

WebDriver is generally an executable that acts as an interface between the browser and the Selenium scripts. The WebDriver executes the native browser commands to perform the tasks. instead of injecting JavaScript in the browser as done by the Selenium RC. Separate WebDrivers are available for different browser and platform combinations. One good thing to note here is that the Firefox browser does not need any WebDriver executable for running the Selenium scripts. After downloading the suitable WebDriver executable, it needs to be added to the PATH variable of the system. Please visit here for complete explaination

Using the WebDriver we can write similar scripts as exported by the Selenium IDE but in a more organized and modular ways. This way reusable components can be created; for example, to send an email one needs to login to the web application and then type in the email content and finlly send it, here the process of signing into application is repeated multiple time for various tasks and will code will be repeated in multiple scripts. This redundancy can be avoided and the process can be modularized and made reusable using the concept of PageObjects. We will revisit the PageObjects topic in great detail later on, but for now it can be thought of a webpage or portion of a webpage that can be reused by making it an object in Java for instance.

To create and run the scripts using WebDriver the latest version of Selenium WebDriver jar needs to be downloaded. After this simply write the script and run it.

A Working Example

    import java.util.regex.Pattern;
    import java.util.concurrent.TimeUnit;
    import static org.hamcrest.CoreMatchers.*;
    import org.openqa.selenium.*;
    import org.openqa.selenium.firefox.FirefoxDriver;

    public class SimpleExample {
        private WebDriver driver;
        private String baseUrl;

        public void setUp() throws Exception {
            driver = new FirefoxDriver();
            baseUrl = "";
            driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

        public void testSimpleExample() throws Exception {
            driver.get(baseUrl + "/#q=selenium");
            driver.findElement(By.cssSelector("div.gsq_a > table > tbody > tr > td > span")).click();
            driver.findElement(By.linkText("Selenium - Web Browser Automation")).click();

        public void tearDown() throws Exception {
        public static void main(String args[]) {
            SimpleExample se = new SimpleExample();

            try {
            } finally {
                if(driver != null) {

Note:While running the above program please make sure to resolve all import issues.
This series of posts will use WebDriver and hence need setup a proper environment for the same.
Now lets start by setting up our environment at the Environment Setup post.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s