Selenium + Java · Lesson 14 of 44
Module 14: Introduction to Selenium
Your task
Implement verifyWebDriverSession:
Write it in the editor, then press Check answer (Ctrl + Enter).
In Selenium 4, the test code directly communicates with browser drivers (ChromeDriver, GeckoDriver, msedgedriver) using the W3C WebDriver Standard over HTTP, eliminating the legacy JSON Wire Protocol overhead.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class FirstSeleniumTest {
public static void main(String[] args) {
// WebDriver initialization in Selenium 4 (Selenium Manager auto-handles driver binaries):
WebDriver driver = new ChromeDriver();
try {
driver.get("https://targetqa.com");
System.out.println("Page Title: " + driver.getTitle());
} finally {
driver.quit(); // Always quit browser session
}
}
}Welcome to Phase 3 of Selenium with Java! In this lesson, we explore Selenium WebDriver, the industry-standard browser automation tool. We examine the WebDriver architecture, the W3C WebDriver specification introduced in Selenium 4, and how Selenium drives real browsers. Let's get started!
Part of the Selenium + Java course (Selenium with Java). Practice this concept live in the Selenium Online Compiler or explore our free automation practice form.
No! Selenium 4.6+ introduces built-in Selenium Manager which automatically discovers, downloads, and configures ChromeDriver and GeckoDriver for you.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___