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 progressGetting Started
3 lessonsBeginner2 videos
Getting Started
3 lessonsBeginner2 videosLocators
7 lessonsBeginner5 videos
Locators
7 lessonsBeginner5 videosCSS and XPath Locators
5 lessonsBeginner5 videos
CSS and XPath Locators
5 lessonsBeginner5 videosWeb Element Interactions
6 lessonsBeginner2 videos
Web Element Interactions
6 lessonsBeginner2 videosDropdowns
6 lessonsIntermediate1 video
Dropdowns
6 lessonsIntermediate1 videoElement States
3 lessonsIntermediate
Element States
3 lessonsIntermediateWaits
5 lessonsIntermediate
Waits
5 lessonsIntermediateAlerts & Popups
4 lessonsIntermediate
Alerts & Popups
4 lessonsIntermediateFrames
4 lessonsAdvanced
Frames
4 lessonsAdvancedWindow Management
3 lessonsAdvanced
Window Management
3 lessonsAdvancedActions Class
5 lessonsAdvanced
Actions Class
5 lessonsAdvancedKeyboard Actions
2 lessonsAdvanced
Keyboard Actions
2 lessonsAdvancedJavaScript Executor
4 lessonsAdvanced
JavaScript Executor
4 lessonsAdvancedScreenshots
2 lessonsAdvanced
Screenshots
2 lessonsAdvancedTables
4 lessonsAdvanced
Tables
4 lessonsAdvancedAdvanced Topics
3 lessonsAdvanced
Advanced Topics
3 lessonsAdvancedPractice on TestKru
Explore the elements and interactions used in these assignments.
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
- Navigate to https://testkru.com/Elements/TextFields
- Find the element with ID lastNameWithPlaceholder
- Get its placeholder attribute value
- 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
- 01Getting Started. 3 lessons. Start ChromeDriver, read the title, navigate, go back and forward.
- 02Locators. 7 lessons. By.id, name, class name, tag name, link text, partial link text and findElements().
- 03CSS and XPath Locators. 5 lessons. CSS and attribute selectors, XPath, contains(), starts-with() and axes.
- 04Web Element Interactions. 6 lessons. Click, sendKeys(), clear, getText(), getAttribute() and getCssValue().
- 05Checkboxes & Radio Buttons. 4 lessons. Click and verify, pre-selected boxes, radio groups and disabled elements.
- 06Dropdowns. 6 lessons. The Select class by visible text, value and index, all options and multi-select.
- 07Element States. 3 lessons. isDisplayed(), isEnabled() and isSelected().
- 08Waits. 5 lessons. Implicit waits, explicit waits for visible, clickable and disappearing elements.
- 09Alerts & Popups. 4 lessons. Simple, confirm and prompt alerts, and alerts in a row.
- 10Frames. 4 lessons. Switch by ID and name, nested frames and back to default content.
- 11Window Management. 3 lessons. Window handles, several windows, window size and position.
- 12Actions Class. 5 lessons. Hover, double click, right click, drag and drop, click and hold.
- 13Keyboard Actions. 2 lessons. Special keys and key events through the Actions class.
- 14JavaScript Executor. 4 lessons. Read values, scroll to an element, click and change the DOM.
- 15Screenshots. 2 lessons. Viewport and element screenshots.
- 16Tables. 4 lessons. Headers, one cell, row and column counts, every cell.
- 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.