Skip to content
CodeKruPro

Practice

Selenium Java Assignments

Learn WebDriver through Selenium Java practice exercises: 70 hands-on assignments, from your first ChromeDriver to frames, windows and the Actions class. Each one runs on real Chrome and is checked when you submit.

  • 70 lessons
  • 17 modules
  • Beginner to Advanced
  • Video walkthroughs
  • Lessons 1 to 10 free

Keep your progress

Signed-in learners keep solved lessons and a leaderboard rank. Lessons also work without an account.

Sign in to save progress

Getting Started

3 lessonsBeginner2 videos
  1. Your First Selenium Script
  2. Navigate Between Pages
  3. Browser Back and Forward Navigation

Locators

7 lessonsBeginner5 videos
  1. Find Element by ID
  2. Find Element by Name
  3. Find Element by Class Name
  4. Find Element by Tag Name
  5. Find Element by Link Text
  6. Find Element by Partial Link Text
  7. Find Multiple Elements with findElements()

CSS and XPath Locators

5 lessonsBeginner5 videos
  1. CSS Selectors - Basics
  2. CSS Selectors - Attribute Selectors
  3. XPath - Basics
  4. XPath Functions - contains() and starts-with()
  5. XPath Axes - Parent and Sibling

Web Element Interactions

6 lessonsBeginner2 videos
  1. Click a Button
  2. Type Text with sendKeys()
  3. Clear and Replace Text
  4. Get Element Text with getText()
  5. Get Attribute Value with getAttribute()
  6. Get CSS Value with getCssValue()

Checkboxes & Radio Buttons

4 lessonsIntermediate1 video
  1. Handle Checkboxes - Click and Verify
  2. Handle Pre-Selected Checkboxes
  3. Handle Radio Buttons
  4. Handle Disabled Form Elements

Dropdowns

6 lessonsIntermediate1 video
  1. Select Dropdown Option by Visible Text
  2. Select Dropdown by Value with selectByValue()
  3. Select Dropdown by Index with selectByIndex()
  4. Get All Dropdown Options with getOptions()
  5. Handle Multi-Select Dropdown
  6. Get First Selected Option

Element States

3 lessonsIntermediate
  1. isDisplayed() - Check Element Visibility
  2. isEnabled() - Check Enabled State
  3. isSelected() - Check Selection State

Waits

5 lessonsIntermediate
  1. Implicit Wait
  2. Explicit Wait - Element Visible
  3. Explicit Wait - Element Clickable
  4. Wait for an Element to Disappear
  5. Wait for Elements Appearing at Different Times

Alerts & Popups

4 lessonsIntermediate
  1. Handle Simple Alert
  2. Handle Confirm Alert
  3. Handle Prompt Alert
  4. Handle Sequential Alerts

Frames

4 lessonsAdvanced
  1. Switch to Frame by ID
  2. Switch to Frame by Name
  3. Handle Nested Frames
  4. Switch Between Frames and Default Content

Window Management

3 lessonsAdvanced
  1. Get Window Handle and Title
  2. Handle Multiple Windows
  3. Window Size and Position

Actions Class

5 lessonsAdvanced
  1. Mouse Hover Action
  2. Double Click Action
  3. Right Click (Context Click) Action
  4. Drag and Drop with the Actions Class
  5. Click and Hold Action

Keyboard Actions

2 lessonsAdvanced
  1. Keyboard - Special Keys
  2. Keyboard - Actions Class Key Events

JavaScript Executor

4 lessonsAdvanced
  1. JavaScript Executor - Get Values
  2. Scroll to Element with JavaScript
  3. Click Using JavaScript
  4. Modify the DOM with JavascriptExecutor

Screenshots

2 lessonsAdvanced
  1. Take Viewport Screenshot
  2. Take Element Screenshot

Tables

4 lessonsAdvanced
  1. Read Table Headers with findElements()
  2. Get a Table Cell Value by Its id
  3. Count Table Rows and Columns
  4. Iterate All Table Data

Advanced Topics

3 lessonsAdvanced
  1. Handle Cookies
  2. Handle Dynamic Elements (Appearing Content)
  3. Get Page Source

Practice on TestKru

Explore the elements and interactions used in these assignments.

Open TestKru

About this course

Selenium Java practice exercises with instant checking

Each of these Selenium Java practice exercises is built around one page of testkru.com: text fields, dropdowns, alerts, frames, tables and more. The task tells you which element to find and the exact lines your program must print, so you know when you are done. You type Java on the lesson page and click Run, and the code drives Google Chrome on our servers, with nothing to install.

The course has 70 lessons in 17 modules. It opens with ChromeDriver and a page title, works through locators, waits, alerts, frames, windows and the Actions class, and closes with JavascriptExecutor, tables and cookies.

How it works

  • Open a lesson and read the task: the testkru.com page, the element to find and the output to print.
  • Fill in the TODO lines of the starter Main class, which already creates a ChromeDriver and quits it. Click Run: your code compiles and drives Google Chrome on our servers. Run it as often as you need.
  • Click Submit, with a free account. The output of your last run is compared with the expected output for 50 points, and a hidden check reads your code for the Selenium calls the task is about, for the other 50. Matching output is enough to mark the lesson solved.

A sample exercise: lesson 4, Find Element by ID

The first lesson of the free Locators module, copied from the course.

The task

  1. Navigate to https://testkru.com/Elements/TextFields
  2. Find the element with ID lastNameWithPlaceholder
  3. Get its placeholder attribute value
  4. Print the result

What you write

  • Code in place of the three TODO lines: find the field with By.id(), read its placeholder attribute and print it in the format below.

Starter code (Main.java)

import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;

public class Main {
    public static void main(String[] args) throws Exception {
        WebDriver driver = new ChromeDriver();
        driver.get("https://testkru.com/Elements/TextFields");

        // TODO: Find element by ID "lastNameWithPlaceholder"
        // TODO: Get its "placeholder" attribute
        // TODO: Print in format: "Placeholder: <value>"

        driver.quit();
    }
}

Expected output

Placeholder: Enter your last name...

Free lessons and Pro

Lessons 1 to 10 are free: Getting Started and Locators, which take you from opening Chrome to finding elements by every locator type. 2 free unlocks a month open later lessons one at a time.

CodeKru Pro, one payment that never renews, opens the rest from CSS and XPath onward and adds a Selenium Java certificate when all 70 are solved.

Hints, guides and videos

Every lesson has hints that you open one at a time. They name the exact Selenium call, and in about half the lessons the last hint is a line of code, so open them in order and stop as soon as you can finish alone.

Video walkthroughs on YouTube cover lessons 1 to 28. Under each task, an "About this lesson" guide explains how the WebDriver call works and the mistakes people make with it.

Who it suits

  • Manual testers taking their first step into Selenium automation with Java.
  • SDETs who want to rehearse WebDriver calls on real pages before a project or an interview.
  • Java learners who want to use their Java on a real browser.

Bring basic Java: a class with a main method, strings, if, for loops and System.out.println. JUnit, TestNG and Maven are not needed. There are no time estimates for these lessons; most early ones need a few lines, and progress is saved to your account.

What you practise: 17 modules

  1. 01Getting Started. 3 lessons. Start ChromeDriver, read the title, navigate, go back and forward.
  2. 02Locators. 7 lessons. By.id, name, class name, tag name, link text, partial link text and findElements().
  3. 03CSS and XPath Locators. 5 lessons. CSS and attribute selectors, XPath, contains(), starts-with() and axes.
  4. 04Web Element Interactions. 6 lessons. Click, sendKeys(), clear, getText(), getAttribute() and getCssValue().
  5. 05Checkboxes & Radio Buttons. 4 lessons. Click and verify, pre-selected boxes, radio groups and disabled elements.
  6. 06Dropdowns. 6 lessons. The Select class by visible text, value and index, all options and multi-select.
  7. 07Element States. 3 lessons. isDisplayed(), isEnabled() and isSelected().
  8. 08Waits. 5 lessons. Implicit waits, explicit waits for visible, clickable and disappearing elements.
  9. 09Alerts & Popups. 4 lessons. Simple, confirm and prompt alerts, and alerts in a row.
  10. 10Frames. 4 lessons. Switch by ID and name, nested frames and back to default content.
  11. 11Window Management. 3 lessons. Window handles, several windows, window size and position.
  12. 12Actions Class. 5 lessons. Hover, double click, right click, drag and drop, click and hold.
  13. 13Keyboard Actions. 2 lessons. Special keys and key events through the Actions class.
  14. 14JavaScript Executor. 4 lessons. Read values, scroll to an element, click and change the DOM.
  15. 15Screenshots. 2 lessons. Viewport and element screenshots.
  16. 16Tables. 4 lessons. Headers, one cell, row and column counts, every cell.
  17. 17Advanced Topics. 3 lessons. Cookies, content that appears later and the page source.

Questions people ask

Is this Selenium Java course free?

The first two modules are: lessons 1 to 10, Getting Started and Locators. A free account can open 2 more lessons a month with free unlocks, and CodeKru Pro opens all 70.

Do I need to know Java first?

Yes, enough to read a short program. The starter code gives you a Main class with the driver already created, and you add a few lines that call Selenium and print the result.

Do I need to install anything?

Nothing. Java, Selenium and Google Chrome run on our servers. The free Selenium Java compiler on this site uses the same setup if you want to try a script of your own.

Are answers provided?

There is no answer page, but the hints get close: the first names the method, and the last is often the line of code itself. Video walkthroughs on YouTube cover lessons 1 to 28.

How long does it take to finish?

The course gives no time estimates. The early locator lessons are a few lines each; the Actions class, frames and tables need more steps. Your solved lessons stay on your account, so short sessions add up.

Should I learn Selenium with Java or Python?

Choose Java if your team's framework is written in Java, or if the job posts you want ask for Java with TestNG or JUnit. If Python suits you better, CodeKru also has a Selenium Python course on the same practice pages.

Is there a certificate?

Yes. With CodeKru Pro, solving all 70 lessons gives you a Selenium Java certificate with a public page and an Add to LinkedIn button.

Will it help with Selenium interviews?

It gives you code you wrote and ran yourself for locators, waits, frames and windows, which makes those topics easier to explain. For question practice, the Selenium stage of CodeKru Interview Prep is the next step.