First Selenium WebDriver Script | Selenium Tutorial

Creating First Selenium WebDriver Script:

Here I don’t want to go in depth to show the first Selenium WebDriver script. I would like to keep it very simple.

Hope you have already installed Selenium WebDriver. If not go through the below mentioned link to download and install Selenium WebDriver.

How To Download And Install Selenium WebDriver

In the first Selenium WebDriver Script, let’s see the below mentioned sceanario using Selenium WebDriver.

To open appropriate URL and verify the title of the home page

i. Open Firefox browser
ii. Go to the specified URL
iii. Verify the title and print the output of the title
iv. Close the Firefox browser

Test Data:
Expected Value: Software Testing Material – A site for Software Testers

To create our first Selenium WebDriver Script, we have to first create a Java Project, Package and Class in Eclipse.

i. Create a Java Project “SoftwareTestingMaterial”
ii. Create a package “seleniumTutorial”
iii. Create a Java Class “FirstSeleniumWebDriverScript”

Test script with an explanation:

(Note: We use // text when we want to comment a single line of code. and use /* text */ when we want to comment multiple lines of code)

Check out the below link for the complete list of Selenium WebDriver tutorials. There is a propaganda in the industry as learning and working on Selenium is very difficult. To be frank, learning Selenium is very easy.

Selenium WebDriver Tutorial

If you are not regular reader of my blog then I highly recommend you to sign up for the free email newsletter using the below link.

Subscribe and get a free eBook and regular updates from

First Selenium WebDriver Script

Rajkumar SM is a founder of SoftwareTestingMaterial. He is a certified Software Test Engineer by profession and blogger & youtuber by choice. He has an extensive experience in the field of Software Testing. He writes here about Software Testing which includes both Manual and Automation Testing. He loves to be with his wife and cute little kid 'Freedom'.

5 thoughts on “First Selenium WebDriver Script | Selenium Tutorial”

  1. Hi Rajkumar,

    eclipse not showing import option for WebDriver for WebDriver driver = new FirefoxDriver();
    could you please help me with this?

    • Hi Shruthi, it might be because of jars.. Check out whether you have added required Selenium Jars in your project or not. Check this post.

  2. Hi Raj,

    somehow eclipse not showing any suggestion. Yesterday it was working fine and all of sudden eclipse not showing any suggestion. I tried to restoring the default options in ‘Windows > Preferences > Java > Editor > Content Assist > Advanced’. and language(clr+space) but it didn’t work for me. I tried all other option which suggested on Google. still it is not working for me. can you please help me out.

    • Hi Shruthi, you said you have tried everything. So i suggest you to try Project – clean.. i think its under window in eclipsw.. also try restart your system.. if you find solution, just let us know how u resolved it

      • Hi Raj,
        I degrade the version of eclipse from oxygen to neon. Now it is working fine.

Leave a Comment

Share via
Copy link
Powered by Social Snap