Get Title of Current Web Page

To get the title of the current web page programmatically using Selenium in Java, call WebDriver.getTitle() function.

WebDriver.getTitle() method returns a string representing the title of the current web page opened in the browser by Selenium.

The following is a simple code snippet to initialize a web driver and get the title of the current web page.

WebDriver driver = new ChromeDriver();
//some code
String title = driver.getTitle();


In the following program, we write Java code to initialize a web driver, visit, and get the title of that web page.

Java Program

import org.openqa.selenium.WebDriver;

public class MyAppTest {
    public static void main(String[] args) {
        System.setProperty("", "/usr/local/bin/chromedriver");  
    	WebDriver driver = new ChromeDriver();
        String title = driver.getTitle();


Tutorial Kart - Best Online Learning Site for Free Tutorials, Online Training, Courses, Materials and Interview Questions - SAP Tutorial, Salesforce Tutorial, Informatica Tutorial, Kotlin Tutorial, Kotlin Android Tutorial, Spark Tutorial, Kafka Tutorial, Node JS Tutorial


1. Initialize web driver and navigate to

Get Title of Current Page - Selenium

2. Print title of the page to console.

Get Title of Current Page - Selenium