Netsparker Web Application Security Scanner

How to create Selenium WebDriver Test using Selenium IDE? - Selenium Tutorial

Today we are going to see how we can record the test case using Selenium IDE & convert recorded script to Java WebDriver format & execute the automated test script using Eclipse. To start with you should have Eclipse, Java & Firefox installed on your machine. You can refer this article “How to run your first Selenium WebDriver script” to set up your environment & ready to execute your first selenium testing tool tutorial.

A. Record a Test case using in Selenium IDE

1) Launch FireFox & open to Selenium IDE by selecting “Tools > Selenium IDE” option.


launch selenium ide


2) Make sure that Selenium IDE window is opened. In Selenium IDE the recording option is turned ON by-default.


Selenium IDE Window


3) Launch FireFox browser & enter URL as same as shown below:
In Google Home page enter search keyword as Google and click on “Google Search” button as shown below:


Selenium WeDriver Google Search


4) Once the recording is done, you will able to see the recorded command in the command section. Turn off the recording option same as mentioned below. Upto this point you have successfully recorded script in Selenium IDE.


Selenium WeDriver Recorded Commands


B. “Enable Experimental Features” from Selenium IDE options

1) Navigate to Options > Options

In Selenium IDE option, select “Enable Experimental Features” check box.


Selenium IDE Enable Experimental Features


2) Navigate to Options > Format & select the “Java/ Junit 4 / WebDriver” option.




3) JavaScript Application dialog will be display. Click on OK button.




4) Now you will able to see the Java code is displayed in Selenium IDE – Source tab. This code will be used for creating Selenium WebDriver code.




C. Create “firstPackage” under Selenium WebDriver project

1) In previous article we have learnt about “How to Create Project in Eclipse IDE?

Launch Eclipse IDE & open same project created in above step.

Right click on project name select option, New > Package.


Selenium WebDriver First Package


2) In New Java Package dialog enter Name as “firstPackage”


Eclipse new java package


3) Once you created the first package, ensure that it is added under “src” folder same as below:


Created first package in Eclipse


4) Right click on newly created package “firstPackage” select option, New > Class.


Create Class in Eclipse


5) In New Java Class dialog box enter class name in Name text box as “GoogleSearch” shown in below screenshot:


Eclipse Class Name


6) Once you created the “GoogleSearch” class, ensure that it is added under “firstPackage” folder same as below:


Eclipse Google Search Class


6) Now copy the Java/Junit4/WebDriver format converted code to from the previously recorded in Selenium IDE Source tab (Step A4).
Without deleting existing code paste the above recorded in Selenium IDE copied code below as shown below:


Selenium java/junit4/webdriver converted code


7) Upon pasting the code you will display some errors in the eclipse, don’t worry in next few steps we are resolving the all errors:


Selenium java/junit4/webdriver converted code error


8) Now in the code you experience that there are two packages, first is “package firstPackage;” & second is the “package com.example.tests;”.
The Class is allow to declare only one package but the copied code is added new package. So copied package is not present in the Eclipse IDE, so let’s comment out the package name “package com.example.tests;”.


Selenium code comment extra package


9) Once you resolve the more than one class declaration error then you will observe few warning messages as shown below:


Selenium code comment extra class


D. Remove the warning messages

1) We can see there are three warning messages shown in the below screen shot. To remove these warning messages, remove or comment the warning message lines.


Selenium WebDriver - comment warning message


2) Two methods called isElementPresent & closeAlertAndGetItsText methods are never used locally, so let’s comment out these two method sections:


Selenium code comment never used methods


3) One more warning message will get displayed once you commenting unwanted methods:




4) To resolve this problem comment out this line as this is never require while executing the code & click on Save All button shown below:


Save All Selenium WebDriver code


Download Code – Below is the final converted code from recorded Selenium IDE code. You can also copy below code & use directly.

package firstPackage;

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

public class GoogleSearch {
  private WebDriver driver;
  private String baseUrl;
  //private boolean acceptNextAlert = true;
  private StringBuffer verificationErrors = new StringBuffer();

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

  public void testGoogleSearch() throws Exception {
    driver.get(baseUrl + "/");

  public void tearDown() throws Exception {
    String verificationErrorString = verificationErrors.toString();
    if (!"".equals(verificationErrorString)) {
  private boolean isElementPresent(By by) {
    try {
      return true;
    } catch (NoSuchElementException e) {
      return false;

  private String closeAlertAndGetItsText() {
    try {
      Alert alert = driver.switchTo().alert();
      if (acceptNextAlert) {
      } else {
      return alert.getText();
    } finally {
      acceptNextAlert = true;


Here we have completed updating the Selenium WebDriver code in Eclipse. Before executing the script please make sure that Firefox browser is installed in your machine as we have used Firefox browser libraries. When you click on Run icon (Ctrl+F11) then your Selenium WebDriver code will be executed successfully.


1) We have recorded a Test case using in Selenium IDE recording feature.

2) “Enable Experimental Features” from Selenium IDE options & converted generated HTML code to JUnit 4/Java/WebDriver format.

3) In Eclipse, created “firstPackage” & Class under Selenium WebDriver project & pasted above automated generated code in class.

4) One by one resolved all error & warning messages observed in code.


Full Access to Selenium Training Series


If you like this Selenium Automation article and you would also like to subscribe to our software testing email newsletter for software testing latest updates , please enter your email below:

Enter your email address:

Check email in your inbox for confirmation to get latest updates Software Testing for free.


21 comments to How to create Selenium WebDriver Test using Selenium IDE? – Selenium Tutorial

  • Aarya

    Thanks for sharing the post

  • Rubin

    Can you please send me the link to download the selenium?

  • Bhuvana

    Can you please tell me “how to write selenium script without using Selenium IDE recording”, that would really help a lot.

    Thanks in advance!!!

  • Anish Kumar

    Good article.. i m in manual testing how can i improve myself in automation?

  • akash

    Hi. I have 12 months of experince in manual testing.I know the basics of JAVA and SQL.
    Now i got opprtunity in 1.ETL Testing and 2.Automation testing ( SELENIUM ).
    Please advice which one to choose for better career growth.

  • Gunasekaran Veerapillai

    really its very useful for testing people who want to start selenium automation. articles r very interesting n used simple words to understand nice work.
    thanks a lot. keep it up!

  • Nisha

    Nice article….
    I am working in a manual testing, Can you please share me the difference between qtp & selenium?

  • Pradeep

    Good one!!!

  • Automation Tester

    Great article.. Encourages one to learn automation. Put on here on right time, Thanks

  • priyanka

    Yes, it’s really needful article for who need to start selenium automation testing.

    Looking for more articles on selenium WebDriver.

  • Muthukumaran

    Simply Superb!!! 🙂

  • sivaram

    very useful post as a beginner in automation it is very easy to learn from this site …Thank u Great effort keep posting such useful info…

  • Kirupakaran

    This is nice one and easy to learning for automation testing…keep more info

  • yogesh dawkhar

    why the given code do not work when we use Chrome driver instead of Firefox Driver. how to settle out this problem. m using Windows7 OS.

  • sue

    if I created more than one selenium script , how would I bundle them to run as a test suite in Eclipse?

  • Innova

    Really helpful article to the beginners,thank you so much.Keep it on.

  • Rakesh

    Its such very helpful tutorial for the beginner like me . But when i used this code it display “sendKeys” error. I have tried to resolve this error many times but didnt get any solution. So can anyone suggest me the right solution.

    See the error listed below:


    The method sendKeys(CharSequence…) from the type WebElement refers to the missing type CharSequence

  • cam

    I am using your site at work, and I just wanted to thank you for putting this together. Amazing resource!

  • vishwas

    Its not working.
    Plz provide step by step to implement Selenium IDE to Webdriver script.

    It shows missing main method error. When i use main method it shows full error.

  • Gaurav

    Nice one!!
    Please provide me process that how can I perform assertion of an object using selenium IDE recording.

  • Rajni

    There is lot of failures under failure trace

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>