Selenium 2 WebDriver Basics With Java

Learn to automate web applications using Selenium WebDriver with Java.
  • Lectures 251
  • Video 22 Hours
  • Skill level all level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

Course Description

Selenium WebDriver is the web automation tool of the moment. Selenium WebDriver skills are in demand. And when you understand the Selenium WebDriver usage patterns that this course teaches, then you can increase your automation effectiveness.

What are the requirements?

  • Windows PC, although instructions should work on Linux or Mac
  • Open source and free tools: IntelliJ IDE, Java SDK, Firefox, Chrome

What am I going to get from this course?

  • Over 251 lectures and 22 hours of content!
  • By the end of this course you will have a working knowledge of the main parts of the WebDriver API
  • You will know how to create effective synchronisation routines to minimise intermittency
  • You will know how to investigate the functionality of WebDriver by looking in the WebDriver code
  • You will know how to craft effective assertions using JUnit and Hamcrest
  • You will understand how to run your tests on different browsers
  • You will know how to use the Selenium Grid
  • You will know how to use JavaScript with your tests
  • You will understand different locator strategies and know how to use both CSS selectors and XPath selectors
  • You will learn productivity techniques and approaches using the IntelliJ IDE

What is the target audience?

  • Testers with some experience of programming
  • Programmers who want to learn browser automation
  • Selenium RC users who want to learn WebDriver

What you get with this course?

Not for you? No problem.
30 day money back guarantee

Forever yours.
Lifetime access

Learn on the go.
Desktop, iOS and Android

Get rewarded.
Certificate of completion


Section 1: Introduction
An overview of the course.
About the Instructor: Alan Richardson
Welcome to the course, a personal message from Alan Richardson - your instructor
Aims are simple. Get you using Java and WebDriver and understand how to automate most of the web and html controls that you will encounter in your automation tasks.

This section is not mandatory. I feel obliged to add a small section on the history of Selenium and WebDriver because every other trainer will, but I do not want to spend a lot of time on the history, because I want to get you coding.

Section 2: Getting Started

A description of the installation of the tools. either follow the lectures that follow my free course

Install Firefox browser and briefly mention Saucelabs as a grid provider

Install firebug and firepath, with reasons why you should and a quick demo of each




FireCookie no longer required as the functionality is now part of firebug

Install Console2 an open source wrapper around command lines e.g. Cygwin or DOS to make later command line based development work easier 

How to find and install the Java SDK

A video showing the installation of Maven. I don't use any extra tools such as Rapid Environment Editor and I show you a common issue that you might encounter when installing Maven, I also explain the thought processes around fixing it.


This is completely optional. You do not have to use this tool. Some people prefer to use the windows properties directly, as shown in the previous video.

Install the Rapid Environment Editor to make it easier to amend Windows Properties


This is an older version of the "Maven 2014" video showing how to install the tool using console and rapidee to help. If you have already done the "Install Maven 2014" video then you do not need to do this. Install Maven, a build and dependency management tool


How to install IntelliJ 13 and create your first test quickly. We expand on this in future videos.


Install IntelliJ Free community edition. I have left this as an older version of the IntelliJ install - most people will want to use the new IntelliJ 13 version now.


The Mac setup seems quite straightforward.

I installed the Java JDK by following the instructions on the oracle site.

I installed maven by following the instructions directly on the site for Mac. And the video on this lecture shows how I did that.

I installed IntelliJ for Mac from the JetBrains site.

I was able to import the projects into IntelliJ and create tests and pom.xml as demonstrated in the Windows lectures. I didn't really find many differences in the installation from Windows to Mac.


To make the exports 'persist' on a mac we have to add them to our bash_profile in our $HOME directory.

You can find the instructions I followed on StackOverflow, or watch the video

Section 3: Logistics and Access to Course Materials
Welcome to the course on Udemy

The Udemy interface can lead to mistakes when asking a question or an answer. I want you to be able to contribute to the course and ask questions so in this video I'll show you how the Udemy interface works for questioning.


How to contact your instructor via Udemy messaging? Udemy haven't made the process of messaging your instructor particularly easy. So I'm going to show you how to do it. The short version is visit the following link and message me:


The supplementary material for this lecture contains the source code for this course. Download the zip file from the materials tab after starting the lecture. Unzip the file and you can import the source code into IntelliJ following the next lecture.

 readme.txt notes for the updates are in the attached .txt files 

Shows how to import the Course source code from a zip file using IntelliJ 13

Demonstration of importing the course source code into IntelliJ 12
233 pages

The slides for the course for offline study. These do not seem to render well in the Udemy viewer, best to download these. They do not currently seem to render using Chrome in the Udemy viewer. They do work in Firefox, and you can download the pdf from the "Extras" tab. Update 11/10/2013 I tried again today and it seems that Udemy site has changed again. I could not get it working in Chrome unitl I right clicked and "save as..." but was able to download it in Firefox. Firefox said "This pdf might not display correctly" [Open With Different Viewer], or click the download link in the top right of the embedded pdf viewer.
7 pages

A set of summary slides and tables that you can use to help remind you of the API usages as you work with WebDriver. Print these out for a handy small reference.

How to get access to the svn repository

A quick overview of how to use the Udemy messaging to request access to the svn repository, and setup an account on xp-dev.

Some people prefer to take the source code from the svn repository. This is exactly the same code as found as a zip file in the earlier lecture.

You can skip this section until later in the course if you want. You don't really need to do this until you reach the lectures on continuous integration later in the course.

Install an SVN client
Checkout the svn project
Create an IntelliJ Project
Svn Update and Svn Export

When using other people's source code you might discover that you receive an error like.

"java: strings in switch are not supported in -source 1.6

(use -source 7 or higher to enable strings in switch)"

Or something similar.

This video shows you the steps I take to avoid it by adding code in the pom.xml file and the checks I make in the IntelliJ IDE to make sure my configuration is correct.

The compiler settings:

File \ Settings \ Compiler \ Java Compiler

The Project and module settings:

File \ Project Structure | Project Settings \ Project

File \ Project Structure | Project Settings \ Modules

Section 4: Create a Project

Basic description of maven, what it does, what we will use it for, and where to find more information on maven.


Use maven from the command line to create a simple maven project, with a brief explanation of the pom.xml file.


You will generally use the most up to date versions of IntelliJ. This shows how to import the initial pom you created using the import wizard of IntelliJ 13. Using import allows you to setup the configuration during the import process, rather than as you work with the project.


You will generally use the most up to date versions of IntelliJ. This shows how to import the initial pom you created using the open wizard of IntelliJ 13. Using Open allows you to setup the configuration after the import process as you work with the project. This is useful when you have more experience and a more fully detailed pom.xml file.


Import the automatically generated pom into an IDE.

This video is a little out of date, and has been retained for historical reasons. You will generally use the most up to date versions of IntelliJ, so look at the updated IntelliJ videos, or the video on how to import the course source code.


We go off to to find the most up to date version and amend the pom file.


Amend the test code automatically generated by Maven


Amend the pom file to include Selenium as a dependency by going off to and seeing what version has been released.


A short summary of why we use maven on this course.

17 pages

Tips for working with Maven. If you experience problems getting started with maven then this slidedeck might help.

General troubleshooting steps for maven. Deleting from the local repo, using "mvn clean compile -DskipTests=true" and a variety of other methods explored.
How to configure maven to use a proxy. Demonstration of what a download error in the maven output looks like. What happens after a download error, and some steps to fix them.
Section 5: Begin Coding

Use HtmlUnit driver to visit and assert that the title starts with "Selenium Simplified"


A little about the WebDriver interface, basic commands on driver and the basics of HtmlUnitDriver


Learn your IDE, "Get a feel for that"

  • Configure for autoscroll
  • Experiment with command completion
  • Learn to view JavaDoc
Own and experiment with the code


Have the test run in Firefox, and changes required to make that happen.

Section 6: Basic Automation Knowledge
What is the basic knowledge you need to automated the web?
Chunking strategy for WebDriver knowledge: Navigate, Interrogate, Manipulate, Synchronise
Section 7: JUnit
Brief introduction to junit with an example test fully explained
A basic overview of how maven finds and downloads the dependencies into a local repository
Demonstrate that 'test' needs to be in the class name for maven to automatically run it when doing "mvn test"
A brief description of @Before, @After, @BeforeClass, @AfterClass and other JUnit annotations
A brief look through the JUnit source code
Using @Before, @BeforeClass, @After and @AfterClass in tests
A short introduction explaining the JUnit exercises that you should do to reinforce your learning. The exercises will take about 30 mins to do. In the next lecture I will explain the sample answers, but you will get most benefit if you do the exercise before watching the answers.
Sample JUnit Answers Explained

How to use the full version of hamcrest with JUnit and Maven. A short discussion of the problem, then demonstration of how to use Hamcrest 1.1 and 1.3 with JUnit 4.10

3 pages

JUnit 4.11 makes it easier to include the Hamcrest matchers in your project. This slidedeck explains how.

Section 8: Navigation
An overview of the basic navigation commands at the driver level.
Explain the Driver class, and difference between the sample code and the slide code.  Learn about JVM shutdown hooks
The navigation exercise will take about 15 - 20 minutes
A walk through of sample answers to the navigation exercises. The refresh exercise required some basic string parsing and we explain this in the video.
Does navigation require synchronisation? And what about clicking why is that not navigation?
Section 9: IntelliJ Hints And Tips

Some useful setup for the project pane in intellij.

Project window settings

 AutoScroll to source/from source

     flatten classes

     show members


An example of short cut keys that can help with Intellij code navigation

navigation short cut keys:

  •   Shift + Cntrl + Alt + N = find symbol
  •   Shift + Ctnrl + N = find file
  •   Cntrl + N = find class

Section 10: Interrogation
A brief introduction to interrogation. 
We can do Interrogation at the driver level and the DOM level. To interrogat at the DOM we have to locate before we interrogate.
Driver level Interrogation exercise
An example test answer shown, and refactored to use assertThat and @BeforeClass & @AfterClass - reasons for doing the refactoring are also explained.
An overview of DOM interrogation. How to locate with findElement and the initial set of By locators
Throw you in at the deep end with an exercise using findElement and By. This should take about 20 minutes or so.
An overview of the sample answers for first findElement and By exercise.
An overview of the findElements method.
Explanation of the exercise to test your understanding of the findElements method. The exercise should take 10 to 15 minutes to complete
An overview of find elements sample, with a preview of xpath usage and demo of findElements which does not match.
Examples of chaining findElement and using the ByChained helper class. Also learn about the ByIdOrName helper class. Drop into the code for ByChained and ByIdOrName and remember you can use these as examples when you want to create your own custom By objects.
Section 11: CSS Selectors
An overview of CSS selectors, and the By.cssSelector location method. CSS selectors are explained using FirePath in firebug.
Create some tests using etc. and convert them to use By.cssSelector
CSS Selectors Exercise - sample answers
Covering popular path selection methods for CSS, parent > child, ancestor descendant, sibling + sibling, and :first-child
The list of CSS references from the slides, with a short description of each link.
Section 12: XPath Selectors
An over view of XPath selectors, online references, and examples of using them in Firebug and JUnit.
This should take about 5 minutes, create some tests using etc. then convert to By.xpath
Sample answers for the XPath exercise
An additional pdf resource to help with CSS and XPath
Section 13: Manipulation

An overview of the basic WebElement manipulation commands, click, clear, sendKeys and submit


An example of what might happen if you try to automate without some additional knowledge. Includes an example of how to inspect the page and construct tests using firebug.


An overview of WebDriverWait and the ExpectedConditions helper class

Section 14: Manipulation - Exercises

An introduction to the manipulation exercises, with an overview of the page that we will be testing and the tasks in the exercise to perform. Also an overview of a sample manipulation test.

So you don't have to keep the slide open, this is the list of exercises for Manipulation, this will take about 30 mins to an hour


An introduction to the sample answers, describing an update to Firefox 16 and how the tests have had to change and new synchronisation added


I submit the form in as many different ways that I could think off, and I'll explain the cross browser issues associated with this. I also caution you on going 'too far' with your automation and try not to test 'in built' browser functionality, unless you want brittle tests.


Look at the clear field and send keys for comments, and consider if waiting for page is necessary in these tests.


Overview of the answer and explain tests with conditional statement to help them setup prerequisites for the test.


I created two examples, one more robust than the other, and I discuss how I could make it yet more robust.


Four different ways of implementing the answer, explained. With an example of refactoring common code into a private method.


Demo of the answer to question 6


Demo of the optional upload file and dealing with file dialog exercise


Summary of the manipulation commands covered. Discussion of 'not getting hung up on file browser dialogs'. Demonstration of how I use tests to answer my own questions about the API. Remember to model the intent of your test and check that the WebDriver API does the same as the real world. A little more information about SendKeys and modifier sequences.

Instructor Biography

Alan Richardson , I test stuff, and help people test better.

Alan is the Author of the book "Selenium Simplified" and the book "Java For Testers". He has talked at conferences the world over, and has been involved in testing for almost 20 years.

In November at Eurostar 2012 Alan co-presented (with Simon Stewart) the "Selenium Clinic" tutorial. They won the award for Best Tutorial.

Alan writes on the following blogs and web sites:

Join the biggest student community


Hours of video content


Course Enrollments




Average Rating
  1. 5 Stars
  2. 4 Stars
  3. 3 Stars
  4. 2 Stars
  5. 1 Stars
    • Girisankar Kannan

    Best Selenium Course

    • Lyle Hodgson

    One of the most helpful and informative courses I've ever taken

    • James Runde

    You need to take this course

    If you want to learn Selenium WebDriver with Java, then you need to take this course. It's one the best courses on Udemy.

    • François Grossin

    Very useful !


    • Folemman

    The course surpassed expectation,

Show more reviews
Ready to start learning?
Preview this course